String type (was: if statement not working)

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

As much of a purist as I am, I must concur that string handling, as well
as handing errors caused by mishandling strings, is grossly inadequate
in Euphoria.

I think it would be a fair statement to say that about half of all
sequences (at some given level) are in fact strings.  When working with
string splices and string comparisons, it is fairly safe to assume that
most people want the simplest and safest operation possible, and let the
interpreter be smart enough to self-correct errors.  Therefore, I
propose the following additions (which have been proposed many times
before) to meet these goals:

1) A built in string type = 1-level sequence containing only integers
ranging from 0..65535.  This should be no more difficult to accomplish
than the built in integer type, and follows naturally with the existing
concept of the language.

2) A "with safe_strings" switch, defaulted to off, that would
intelligently handle string related errors rather than crashing the
program.  Use of this switch would automatically throw a warning rather
than an error when such a condition is encountered.  The two following
errors would be the easiest to fix:

2a) if x[1..3]="I" then ... : Rather than crash, simply return 0.  It's
intuitive, expected; and if well documented, won't cause confusion.  

2b) referencing past the end of a string (i.e., x[1..inf]) should
return up to the end of the string instead of crashing.  This
intelligence would also take care of the ..length(x)] shortcut that has
oft been discussed here, with the shortcut being the built-in atom
"inf".

Personally, I believe these behaviors should be the default in any
interpreter.  However, the safe_strings switch fits in better with the
strict programming style paradigm that Rob adheres to.  I'm not
expecting anything, but I would like to hear Rob's view on why these
behaviors go against the Euphoria philosophy.

Michael J. Sabal

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

Search



Quick Links

User menu

Not signed in.

Misc Menu