[Ohrrpgce] Fwd: HSpeak, plotscripting arrays
TeeEmCee
teeemcee at gmail.com
Wed May 25 16:10:07 PDT 2005
---------- Forwarded message ----------
From: Bob the Hamster <bob at hamsterrepublic.com>
Date: Feb 25, 2005 2:38 PM
Subject: Re: HSpeak
To: TeeEmCee <teeemcee at gmail.com>
That sounds like a fantastic plan. I fully approve.
It would probably be a good idea to add a command-line option to hspeak
to supress the array support, for the benefit of anybody who might have
already written scripts that use [ and ] in names.
Also, IIRC, the code in CUSTOM that generates HSI files does not strip
out [ and ], so it should be made to do so.
---
James
On Fri, Feb 25, 2005 at 01:33:38AM +1300, TeeEmCee wrote:
> Ah. The plan was to make arrays static objects that would be declared
> (in the case of local arrays) with 'variable', and the compiler would
> then increase the local count by however many elements the array has.
> Local variables with names like 'array[1][1][1]' would be silently
> created for each element.
>
> Of course, the script could always write out of bounds, but this would
> be just as easy to do with 'write global'. Except, you wouldn't get a
> nice error message...
>
> Anyway, here what I've worked out :
> An array can take either the form array[1][2][3] or array[1,2,3].
> Which means [ and ] can't be used anymore except for arrays, but I
> think I was the about only person to use them anyway, and not
> seriously. Any number of dimensions.
> I'll try and create new kinds, which will never appear in a compiled
> script, and add some new code to fix_arguments to convert arrays to
> math functions there. Any suggestions?
>
> TMC
>
> On Wed, 23 Feb 2005 12:13:46 -0800, Bob the Hamster
> <bob at hamsterrepublic.com> wrote:
> > On Thu, Feb 24, 2005 at 08:29:15AM +1300, TeeEmCee wrote:
> > > Maybe I should ask how the heap space is organised. Is anything else
> > > besides locals and return values for scripts stored in it? I presumed
> > > that It was filled from the beginning, with a return value and then
> > > local variables 'allocated' in it as scripts are loaded. If this was
> > > the case, it wouldn't be possible to write over other scripts'
> > > varibles, because you can't access anything lower than the first local
> > > of the current script?
> >
> > Honestly, I don't rememeber exactly how I organized it :)
> > let me check...
> >
> > Okay. Each script instance keeps an index of where in the heap it keeps
> > its local values. arguments come first, followed by local variables. It
> > WOULD be possible to retrieve these values by index relative to this
> > offset, but there could be complications.
> >
> > Consider this:
> >
> > "scriptA" has two arguments and one local variable. It is the first
> > script run, so it uses heap values 0,1,2
> >
> > "scriptB" has no arguments, and uses one local variable.
> >
> > if scriptA calls scriptB, then scriptB will use heap value 3 to store
> > its local variable
> >
> > If scriptA does uses a hypothetical command to modify heap values, and
> > THEN calls scriptB, how do we prevent scriptB from clobbering any values
> > manually written by scriptA past the end of its own section of the heap?
> >
> > there would need to be a mechanism to allow a script to keep track of
> > the highest heap value it has modified, so that any sub-scripts it calls
> > know to start their heap usage AFTER that point.
> >
> > It can be done, but it requires some thought to do it right.
> >
> > > Umm.. forget fake strings. They were for passing masses of data, but I
> > > don't think anyone but me wil use them.
> > >
> > > I suppose you're right- I'm a little obsessed with plotscripting :)
> >
> > I know the feeling well :)
> >
> >
> > > TMC
> > >
> > >
> > > On Mon, 21 Feb 2005 09:12:09 -0800, Bob the Hamster
> > > <bob at hamsterrepublic.com> wrote:
> > > > The trouble with writing directly to the heap space, is that the heap
> > > > works very differently from the globals. It could be done, but you would
> > > > have to worry about not clobbering the heap space of other functions.
> > > >
> > > > the heap space is kinda bigger than it needs to be. If I could get some
> > > > real-life benchmarks of how much heap gets used in the most complicated
> > > > plotscripted games, maybe I could re-allocate some of that data.
> > > >
> > > > How do you envision using fake strings?
> > > >
> > > > I think your programming skills have far outgrown plotscripting, and you
> > > > should be using your talents on a real language-- but if you still want
> > > > to try to implement these features, I would welcome them.
> > > >
> > > > ---
> > > > James Paige
> > > >
> > > > On Mon, Feb 21, 2005 at 08:41:29PM +1300, TeeEmCee wrote:
> > > > > Yes, I could use read global and write global, but I wanted to have
> > > > > local arrays as well. 4096 bytes of heap space for locals seems wasted
> > > > > when I have to ration globals due to arrays.
> > > > >
> > > > > I also wanted to implement (somewhat) real arrays (I suppose that
> > > > > technically, they're still fake), which would be delared like
> > > > > variable(ctr1, ctr2, myarray[5][5]). Upon seeing something like
> > > > > myarray[ctr1][ctr2] (I might have to change to somthing like
> > > > > myarray(ctr1,ctr2)), it would be translated into a variable reference
> > > > > with an id that is the element number plus some offset to the start of
> > > > > the array, global or local no.
> > > > >
> > > > > I also had some more exotic ideas, like fake strings (a string
> > > > > enclosed in " " would be converted into multiple arguments, each with
> > > > > the value of the constant representing a character in the string) and
> > > > > getting arguments for a script passed into an array.
> > > > >
> > > > > ...
> > > > >
> > > > > But if the engine is going to become opensource, I could probably
> > > > > implement a math function myself... :o
> > > > >
> > > > > Mad Cacti
> > > > >
...
More information about the Ohrrpgce
mailing list