Re: sequence length allocation

new topic     » goto parent     » topic index » view thread      » older message » newer message

The problem I have with this is that your intention is not known.
If you code...
  s[5] = 'o'
the compiler has to guess between two options,
a) You want to extent the sequence,
b) You made a mistake with the index number.

As b) is a real possibility, the safer way of doing
this is to tell the compiler what it is you are trying
to do. Maybe something like...

  s[#5] = 'o'

to explicilty and simply tell the compiler that
you are extending the sequence and element 5 is
to be set to 'o'. Of course, what happens to the
elements between the existing last one and the 5th
one is a mystery. So maybe even this ...

  s[#] = 'o'

could be used to say "append to the sequence". This
way you wouldn't have to know its current length.

cheers,
Derek Parnell
dparnell @ vic.bigpond.net.au
Melbourne, Australia
-----Original Message-----
From: Alan Tu <ATU5713 at COMPUSERVE.COM>
To: EUPHORIA at cwisserver1.mcs.muohio.edu
<EUPHORIA at cwisserver1.mcs.muohio.edu>
Date: Wednesday, August 5 1998 23:32
Subject: sequence length allocation


|I run the following simple program:
|
|sequence s
|s = "hell"
|s[5] = 'o'
|
|Most of you will immediately recognize that there is an error here, because
|I allegedly assigned a fifth value to a length 4 sequence.  Well, I plead
|guilty, but I appeal because this should not be illegal.  Sure, I can use
|append, but the above syntax seems a lot more straightforward.  What would
|we loose?  Also, I still have a initialize every sequence and specify at
|least an initial length.  This is not complete dynamic storage allocation,
|to me.
|
|At least, I feel there should be a sequence initialized as an indefinite
|length.
|
|In Euphoria, I still have to initialize the sequence, and tell Euphoria
|what length it should be initially.  There are tools to append and prepend,
|but that only masks the truth that we still have to tell Euphoria what the
|length of the sequence is.  It seems that if I have a database, with one
|sequence with each sub-sequence being a record, I could just simply do
|something like this:
|
|s[length(s)+1] = new record
|
|I feel this is a more direct approach, than append could ever be.
|Although, it is possible that C, which Euphoria is written in, forces
|Euphoria to be like this.
|
|Just a thought.
|
|Alan
|

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu