Re: true/false atoms?

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

--------------2027F04DCF1AF9F80DF020AA

COULD SOMEONE PLEASE FIX THE E-MAIL ADDRESS. ALL THESE MESSAGES ARE COMING TO
GRAFTON CITY LIBRARY !!!!! WE HAVE HUNDREDS OF MESSAGES!!!!!!!!!
THANKS - I HOPE


Kat wrote:

> ----- Original Message -----
> From: Roderick Jackson <rjackson at CSIWEB.COM>
> To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
> Sent: Thursday, August 12, 1999 3:04 PM
> Subject: Re: true/false atoms?
>
> > Kat wrote:
> > >> It's a real waste (and poor programming practice)  to use "strings" as
> > >boolean
> > >> values.
> > >
> > >Ok, how do *you* do a flag in eu that can be 5 values when you are
> protyping
> > >in a new language and are stressing easy readability over speed and
> > >compactness?
> >
> > Well, here's the way I would do it:
> >
> >     -- the set of values for my special user-defined type
> >    constant FALSE   = 0
> >    constant TRUE    = 1
> >    constant SPECIAL = 2
> >    constant ERROR   = 3
> >    constant OTHER   = 4
> >
> >     -- this type declaration isn't necessary, but if you prefer
> >     -- tighter error checking, this helps
> >    type MyType (object x)
> >       if (integer (x)) then
> >          if (x <= FALSE) and (x >= OTHER) then
> >             return 1
> >          end if
> >       end if
> >       return 0
> >    end type
> >
> >    MyType Flag -- or, just "integer Flag" works
> >
> >    if (Flag = ERROR) then
> >
> >     ...and so on...
> >
> > Key rule when converting user-defined types from a language like
> > Pascal: use integer constants. Works exactly the same, and is just
> > as readable. Most Euphoria programs, at the very least, define
> > FALSE and TRUE to be 0 and 1.
>
> Ok, all that's nice, but all that stuff is just why i was trying out
> Euphoria, to get away from restrictions in pascal, etc. I have written more
> code than actual program to do type translations, mapping one var on top of
> another and other tricks so i could use the var how i wanted to, making sure
> if i deallocated the one var that all those others mapped onto it were also
> not used again, etc etc. I figure the puter is here to make my life easier
> and do what i want, it's not here so i can learn new programming methods or
> tricks and put restrictions on what i can do. If i want to have the flag
> accessed by another program or passed to another procedure/function, strings
> (or sequences) are the least likely to trigger a type error (just type
> everything as a string(oops, sequence)) , and i can set them to anything,
> and parse what i want out of them as needed. Of course, the parsing was
> easier in pascal with the goto or case statements (when the case statement
> didn't choke on a type error, anyhow). With faster processors than the 6502
> and memory cheaper than the $125 i once paid for 64K, i am not so concerned
> about waste anymore,, once the program runs like i want it to, the "proof of
> concept" is done, i'll optimise it for *speed* more than anything else.
>
> Kat
> noting that everything she does to get around compiler deficits is poor
> programming practice.

--------------2027F04DCF1AF9F80DF020AA

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<B>COULD SOMEONE PLEASE FIX THE E-MAIL ADDRESS. ALL THESE MESSAGES ARE
COMING TO GRAFTON CITY LIBRARY !!!!! WE HAVE HUNDREDS OF MESSAGES!!!!!!!!!</B>
<BR><B>THANKS - I HOPE</B>
<BR><B></B>&nbsp;<B></B>
<P>Kat wrote:
<BLOCKQUOTE TYPE=CITE>----- Original Message -----
<BR>From: Roderick Jackson &lt;rjackson at CSIWEB.COM>
<BR>To: &lt;EUPHORIA at LISTSERV.MUOHIO.EDU>
<BR>Sent: Thursday, August 12, 1999 3:04 PM
<BR>Subject: Re: true/false atoms?
<P>> Kat wrote:
<BR>> >> It's a real waste (and poor programming practice)&nbsp; to use
"strings" as
<BR>> >boolean
<BR>> >> values.
<BR>> >
<BR>> >Ok, how do *you* do a flag in eu that can be 5 values when you are
<BR>protyping
<BR>> >in a new language and are stressing easy readability over speed
and
<BR>> >compactness?
<BR>>
<BR>> Well, here's the way I would do it:
<BR>>
<BR>>&nbsp;&nbsp;&nbsp;&nbsp; -- the set of values for my special user-defined
type
<BR>>&nbsp;&nbsp;&nbsp; constant FALSE&nbsp;&nbsp; = 0
<BR>>&nbsp;&nbsp;&nbsp; constant TRUE&nbsp;&nbsp;&nbsp; = 1
<BR>>&nbsp;&nbsp;&nbsp; constant SPECIAL = 2
<BR>>&nbsp;&nbsp;&nbsp; constant ERROR&nbsp;&nbsp; = 3
<BR>>&nbsp;&nbsp;&nbsp; constant OTHER&nbsp;&nbsp; = 4
<BR>>
<BR>>&nbsp;&nbsp;&nbsp;&nbsp; -- this type declaration isn't necessary,
but if you prefer
<BR>>&nbsp;&nbsp;&nbsp;&nbsp; -- tighter error checking, this helps
<BR>>&nbsp;&nbsp;&nbsp; type MyType (object x)
<BR>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (integer (x)) then
<BR>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (x &lt;=
FALSE) and (x >= OTHER) then
return 1
<BR>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if
<BR>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if
<BR>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0
<BR>>&nbsp;&nbsp;&nbsp; end type
<BR>>
<BR>>&nbsp;&nbsp;&nbsp; MyType Flag -- or, just "integer Flag" works
<BR>>
<BR>>&nbsp;&nbsp;&nbsp; if (Flag = ERROR) then
<BR>>
<BR>>&nbsp;&nbsp;&nbsp;&nbsp; ...and so on...
<BR>>
<BR>> Key rule when converting user-defined types from a language like
<BR>> Pascal: use integer constants. Works exactly the same, and is just
<BR>> as readable. Most Euphoria programs, at the very least, define
<BR>> FALSE and TRUE to be 0 and 1.
<P>Ok, all that's nice, but all that stuff is just why i was trying out
<BR>Euphoria, to get away from restrictions in pascal, etc. I have written
more
<BR>code than actual program to do type translations, mapping one var on
top of
<BR>another and other tricks so i could use the var how i wanted to, making
sure
<BR>if i deallocated the one var that all those others mapped onto it were
also
<BR>not used again, etc etc. I figure the puter is here to make my life
easier
<BR>and do what i want, it's not here so i can learn new programming methods
or
<BR>tricks and put restrictions on what i can do. If i want to have the
flag
<BR>accessed by another program or passed to another procedure/function,
strings
<BR>(or sequences) are the least likely to trigger a type error (just type
<BR>everything as a string(oops, sequence)) , and i can set them to anything,
<BR>and parse what i want out of them as needed. Of course, the parsing
was
<BR>easier in pascal with the goto or case statements (when the case statement
<BR>didn't choke on a type error, anyhow). With faster processors than
the 6502
<BR>and memory cheaper than the $125 i once paid for 64K, i am not so concerned
<BR>about waste anymore,, once the program runs like i want it to, the
"proof of
<BR>concept" is done, i'll optimise it for *speed* more than anything else.
<P>Kat
<BR>noting that everything she does to get around compiler deficits is
poor
<BR>programming practice.</BLOCKQUOTE>
</HTML>

--------------2027F04DCF1AF9F80DF020AA--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu