Re: String?

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

On Mon, 31 May 2004 09:33:25 -0700, Rolf Schr=F6der
<guest at RapidEuphoria.com> wrote:

>Excuse me, but now I think YOU are missing the point: the decision, if you=

>want to print it as an ASCII string or if you want to print simply the
>numbers, the decision comes by selection the 'tool' YOU select: format {%s=
}
>in printf() gives you the text, and i.e. format {%d,%d,%d,%d} in printf=
=20
>would give you the plain numbers.
>
Hi Rolf,

OK, I agree that in more than 90% of print cases, the programmer can
easily apply the correct format info, however:

Slightly restating the previous example:

sequence weights
	weights={74,111,104,110}
sequence name
	name="John"

There is additional meaning obvious to anyone reading the source,
which is lost in the assignment. Since equal(weights,name) will return
true, any attempt at an "IsString" function is doomed to get one of
them wrong. Sure you can do something like:

constant tInt=1, tFlt=2, tSeq=3, tStr=4

	weights={tSeq,{74,111,104,110}}
	name={tStr,"John"}

Which I think is about the easiest way to preserve the semantic
information. Not exactly nice though, is it?

There may not be a whole lot a string type will allow that you cannot
possibly do without. But to imply it has no merit is silly.

Adding strings might more than double the program size and probably
make everything 50% slower, so I could accept an argument against it
on technical grounds.

But being able to read values in the trace window, ex.err, and output
from ?weights and ?name, is an overwhelming argument in favour.

Of course you may actually be the second person on the planet that
actually likes to see name (and weights) in the trace window appear as
{74J,111o,104h,110n} ?

That definitely falls into the class of Necessary Evil, not the realm
of Good Ideas.

Regards,
Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu