by comcast.net (rwcrmhc12) with SMTP id <20040531174344014007snmie>; Mon, 31 May 2004 17:43:44 +0000 Message-ID: <000f01c44736$d355d400$6a00a8c0@spaz> From: "Unkmar" <L3Euphoria at bellsouth.net> To: <EUforum at topica.com> References: <358272558-1463792382-1086021205 at boing.topica.com> Subject: Re: String? Rob! Date: Mon, 31 May 2004 13:43:41 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2739.300 Ok, this subject is tricky. Reason:
integer i i = 45 if atom(i) then -- TRUE puts(1, "This object can be atom.\n") end if
More than one thing is typically wanted with the inclusing of a string type= . 1. Use less RAM 2. Differentiate between set of numbers and string of text. 1. use a byte per item instead of 4. 2. Is this thing a "John" or is it {74, 111, 104, 110}. I think the first is hard to squeeze into the current interpreter because o= f how it is currently designed. I think the second is doable by implenting a new type of function. Example:
integer i i = 45 if is_atom(i) then -- FALSE puts(1, "This object is declared as an atom.") end if
I'm not saying to do away with atom() or to replace it. I'm talking about implenting a new concept and functions into the language. This would allow for a distintction between "John" and {74, 111, 104, 110}. Under the hood they can remain the same. Even better. String never has to become an actual defined type. It could be a user defined type. And better yet. Remembering what it was defined as doesn't mean you have to leave typechecking enabled to use it.
type string(sequence s) return s end type string text text = "John" if is_string(text) then puts(1, text) else printf(1, text) end if
Now here comes the rub. We still don't have structures. So each object within a sequence is still undeclared. So passing literals or indexed items to is_string() would be an error. Rob, How about them structures? unkmar ----- Original Message ----- From: "Rolf Schr=F6der" <guest at RapidEuphoria.com> To: <EUforum at topica.com> Sent: Monday, May 31, 2004 12:33 PM Subject: Re: String? Juergen Luethje wrote: > > Rolf wrote: > ... > > As I know, a character is a byte that represents a human readable or > > printable symbol. A character string (synonymous: string) is a series o= f > > characters. i.e., a series of bytes representing human readable|printable > > symbols (words, sentences,...). > > Again: I never heard or read, that the definition of "character" or > "string" depends on the question, whether or not something is printable. > E.g. in BASIC, this is clearly *not* the case. You might also want to > look here: > <a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?characters">http://fol= doc .doc.ic.ac.uk/foldoc/foldoc.cgi?characters</a> > <a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?string">http://foldoc.= doc .ic.ac.uk/foldoc/foldoc.cgi?string</a> > J=FCrgen, I see just that stated there what I said, may be with different words. I got this (computer related) definition from: "Dictionary of Computer Terms" (Webster's) and also from "Computer & Internet Dictionary" (Random House). What is a character for you then (computer related)? Later you wrote: > Like him, you are missing the point. > Using such a user-defined string type doesn't solve the problem: If a > Euphoria program reads e.g. {74,111,104,110} from a file, there is no way= > to find out, whether this sequence means "John", or the weight of the > members of my family, or whatever. That's true, specially if a fith byte woul be a zero! 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 would give you the plain numbers. Sincerely, Rolf