Re: String?

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

Irv Mullins wrote:

> Makes me wonder why, if that can be done, what is it so hard to
> differntiate between a double quote and a curly bracket?

By ensuring that pointers fall on four byte boundaries, and dropping the 
precision of integers, Euphoria frees up a couple bits in the C int datatype, 
which it uses to flag the type stored inside, which is something like:

   - positive integer
   - negative integer
   - pointer to atom
   - pointer to sequence
   - undefined

Since there's no remaining bits in the int that can be used to flag the 
datatype, the only other "simple" option would be to add an extra field to 
the sequence structure.

The addition of the field wouldn't be too expensive, but you'd then have to 
perform an additional test on sequences to determine:

   1. Is the sequence a string?
   2. If it's a string, is it still a string after the last operation?

Some operations - concatenation and slicing - would be "free", since you 
guarantee that the data in the sequence would still be a string. But for 
other operations - bitwise, math and comparison - you'd have to scan the 
string to ensure that it was still a valid string.

Since any sequence could possibly be a string (you don't know until you test 
it), Euphoria would have to perform at least the first test on all sequences. 
This is guaranteed to slow things down a bit, I think that'll be a hard thing 
to sell to Robert.

-- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu