Re: better flatten()?

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
petelomax said...

and (btw) I'm just using the Phix builtin string() function here

What are the differences between this and from the OE std string() function ? http://openeuphoria.org/docs/std_types.html#_2199_string

Aside, of course, from the obvious (speed!)....

The other obvious one is that you don't need to include anything to invoke string() in Phix, which is mainly why I mention it.

Otherwise nothing major, except that in Phix strings can get auto-expanded to dword-sequences, which leads to the subtle difference:

sequence s 
s = "fred"  -- string(s) yields true on Phix and OE 
s &= -1     -- string(s) yields false on Phix and OE 
s = s[1..$-1] -- string(s) yields false on Phix but true on OE 

Obviously in Phix, if you want something to stay a string you keep it in a string, so that anomaly is very unlikely to happen.

You could also argue that last true on OE is a bit of a "false positive" in the sense that it looks like a string, but it probably ain't really supposed to be one by then.

Oh, I forgot about declaration semantics:

string("fred") -- true on Phix and OE 
string({'f','r','e','d'}) -- false on Phix, true on OE. 

You can of course puts() etc dword_sequences as if they were strings, without any hassle.

Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu