Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Generating words and global variable space

 [1/10] from: doug::vos::eds::com at: 22-Mar-2001 8:30


Is this what you are looking for?
>> help use
USAGE: USE words body DESCRIPTION: Defines words local to a block. USE is a native value. ARGUMENTS: words -- Local word(s) to the block (Type: block word) body -- Block to evaluate (Type: block)

 [2/10] from: dankelg8:cs:man:ac at: 22-Mar-2001 13:56


Hi Doug, I don't think this is the solution. Let me illustrate the problem: forever [to-word join 'x counter: counter + 1]
>> counter: 0
== 0
>> forever [to-word join 'x counter: counter + 1]
** Internal Error: No more global variable space ** Where: to-word ** Near: to word! :value
>> use [new-word] []
** Internal Error: No more global variable space ** Near: to word! :value I need to generate lots of new words without filling up the global variable space. It seems this is not possible. Gisle On Thu, 22 Mar 2001, Vos, Doug wrote:

 [3/10] from: doug:vos:eds at: 22-Mar-2001 9:31


Why do you want to generate all the new words? Why not use blocks or objects? I have thousands of lines of rebol script and rarely use more than 3 or 4 global words per script. I mostly use local words and global objects. Can you explain more what you are trying to do? Then I'm sure people will be able to help...

 [4/10] from: jelinem1:nationwide at: 22-Mar-2001 8:41


Correct, this is not possible. I've explored this topic in some depth awhile ago, before the limit was raised. ANY word, whether global, local to a context, an element to an object, a refinement, etc and irregardless of value (even undefined words, if they are referenced even once) are put into /system/words. I have created a work-around, though it will not work if you are dynamically generating words. I have written a pre-processor to a REBOL script which will replace all function locally-declared words and function parameter words with generic names (which get reused with each context). The amount of word reduction depends on your coding style, and the tasks you are doing. For the project I was working on, this helped alot. - Michael Jelinek Gisle Dankel <[dankelg8--cs--man--ac--uk]>@rebol.com on 03/22/2001 07:56:19 AM From: Gisle Dankel <[dankelg8--cs--man--ac--uk]>@rebol.com on 03/22/2001 07:56 AM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: "['rebol-list--rebol--com']" <[rebol-list--rebol--com]> cc: Subject: [REBOL] Re: Generating words and global variable space Hi Doug, I don't think this is the solution. Let me illustrate the problem: forever [to-word join 'x counter: counter + 1]
>> counter: 0
== 0
>> forever [to-word join 'x counter: counter + 1]
** Internal Error: No more global variable space ** Where: to-word ** Near: to word! :value
>> use [new-word] []
** Internal Error: No more global variable space ** Near: to word! :value I need to generate lots of new words without filling up the global variable space. It seems this is not possible. Gisle On Thu, 22 Mar 2001, Vos, Doug wrote:

 [5/10] from: dankelg8:cs:man:ac at: 22-Mar-2001 15:58


On Thu, 22 Mar 2001, Vos, Doug wrote:
> Why do you want to generate all the new words? > Why not use blocks or objects?
<<quoted lines omitted: 3>>
> Can you explain more what you are trying to do? > Then I'm sure people will be able to help...
OK. :) First, as Michael pointed out, it doesn't matter where you define a word, it will be added to System/words when it is first encountered by Rebol. I'm writing a simple Prolog interpreter where the format of the rules are like this: [[father 'Bill 'Bob]] [[mother 'Ann 'Bob]] [[parent x y] [father x y]] [[parent x y] [mother x y]] [[grandparent x y] [parent x z] [parent z y]] And so on. Variables must be renamed before unification to aviod name clashes. For example, [[parent x y] [father x y]] could become [[parent _x20 _y15] [father _x20 _y15]] In deep search trees, I quickly run out of variables. There are ways to solve it, but it would make the algorithm slower. Since it's not enormously efficient at the moment, I thought I'd check if there were any other way. Gisle

 [6/10] from: d4marcus:dtek:chalmers:se at: 23-Mar-2001 0:06


On Thu, 22 Mar 2001, Gisle Dankel wrote:
> I'm writing a simple Prolog interpreter where the format of the rules are
Interesting. May I ask how you define the parse rules, by hand or by using some predefined BNF description? I wouldn't hope for the latter, imagining that as a relational language, Prolog doesn't have a large syntax.
> In deep search trees, I quickly run out of variables.
If it's just variables, perhaps you could try using strings instead. Store them in a dictionary with their values. Hmm, maybe you have already thought of this...
> There are ways to solve it, but it would make the algorithm slower.
Suppose it would. :-( Marcus ------------------------------------ If you find that life spits on you calm down and pretend it's raining

 [7/10] from: dankelg8:cs:man:ac at: 23-Mar-2001 17:04


On Fri, 23 Mar 2001, Marcus Petersson wrote:
> On Thu, 22 Mar 2001, Gisle Dankel wrote: > > > I'm writing a simple Prolog interpreter where the format of the rules are > > Interesting. May I ask how you define the parse rules, by hand or by using > some predefined BNF description? I wouldn't hope for the latter, imagining > that as a relational language, Prolog doesn't have a large syntax. >
Hm, not sure what you mean here. Prolog requires almost no parsing. I have defined some rules for 'parse that validates a prolog program, and they are a few lines in BNF style. A prolog interpreter is not difficult to implement either if it's done in a straightforward way. I'll release it later along with the rest of my project. Maybe someone knows how to implement a Warren abstract machine or something similar? I can solve the variable problem temporarily by using a datatype like money! or tuple! instead of word!. But that means you can't write prolog programs with those types.. It's quite interesting to mix rebol with prolog. Rebol can for example generate facts for prolog, which makes it much easier to reason about models which are cumbersome to write in prolog. Gisle

 [8/10] from: dankelg8:cs:man:ac at: 22-Mar-2001 13:02


Hi list, do anyone know of a way to generate words without running out of global variable space? E.g. generating them in a local context? Gisle

 [9/10] from: g:santilli:tiscalinet:it at: 24-Mar-2001 18:25


Hello Gisle! On 22-Mar-01, you wrote: GD> Variables must be renamed before unification to aviod name GD> clashes. For example, [[parent x y] [father x y]] could GD> become GD> [[parent _x20 _y15] [father _x20 _y15]] Could you use different contexts instead of renaming words? Just a thought, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [10/10] from: dankelg8:cs:man:ac at: 24-Mar-2001 18:41


Hi Gabriele, yes, you're right, and I've solved it now :) Frank Sievertsen gave me that idea in the prolog thread. Gisle On Sat, 24 Mar 2001, Gabriele Santilli wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted