Re: Why Types?

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

Hi John,

Most built-in Euphoria built-in functions and procedures work on either
atoms or sequences. Personally, I tend to write code that treats atoms and
one-element sequences the same (so essentially, I have eliminated atoms and
"everything's a sequence"), but I consider this somewhat experimental, and
to a certain extent it may be a function of the particular application I'm
writing. In other words, it might make less sense in other contexts.

Type checking helps prevent subtle errors in programs.

My personal philosophy, based on more than decade of experience producing
commercial software, is that *clarity* is the most important quality a
program can have. If the author is perfectly clear on what the program, and
each component thereof (down to the level of individual statements), must BE
and DO, and if the program presents its functionality in a clear and
"intuitive" manner to the user, and the documentation is clear and explicit,
then "magically" everything works !!! and everyone is happy !!!

Any language feature that promotes clarity is a good one, in my book. I
think Euphoria's definition of type does that, without being overly
restrictive.

Try programming in a typeless language, a strongly-typed one, and a
loosely-typed one. Doubtless you will find situations in which any given
approach is advantageous. Euphoria's type system is very flexible. I like
it.

George Henry

----Original Message Follows----
From: John
Reply-To: Euphoria Programming for MS-DOS
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: Why Types?
Date: Wed, 13 Dec 2000 08:08:57 -0500
Can Euphoria be a scripting or shorthand lanaguage?
consider this;
in EUPHORIA;
integer s
s=rand(100)
in QBasic;
a% = INT(RND * 100)
In this dummy Qbasic statement %A = int(RND) , %A is an integer type yet
we still had to declare the value of (RND) as an INT type , duh...
(some BASIC will let you do "%A=5" but others make you "defTYPE")
Before you can use a variable most "languages"
Require/Demand that you;
1. declare the type
2. assign a value
For short hand or scripting language this is
just not needed.
in JAVAscript;
VAR D="yes" ; assigns VALUE and indirectly declares TYPE
To make Euphoria "user friendly" why not "ASSUME object"
>From what I see ( I am very new to euphoria) anything that is a sequence
can be an integer or string...?big question mark
if I change
integer s to ; sequence s
s=65 ; s=65 --doe it not work?
No it does not , I get ; type_check failure, s is 65'A'
if I attempt a 1 element array or sequence will it work?
s=(65)
puts(1,s[1]) ; No again, it will not . ok try object?
object s
s=65
yes it works ie.. "? S"-outputs 65 and "puts(1,s)" outputs A
Can it handle "any" arbritary assignment?
s=a65 no
s=(A 65) no
s=("A" 65) no
s can not be both 65 and A in Euphoria?
( I think the manual says that too, atoms are numeric only)
You should be able to declare TYPE and METHOD in the way
You choose to implement it .. ie s=A and 65 then s=65 for numeric
expressiona and s= A for text expression. Is this "forward referencing?"
if A=900 not a printable charactor ,then I could understand.
I would expect Ex.err to say "s TYPE 900 is invalid TEXT", but only
if I attempt to "use" it as TEXT.
Its at this point I entered "point" into GURU (very handy ! )
but all I get is mouse pointer and c_pointer info but there is one mention
under
"performance" about euphoria using pointers in sequence type structures...
but from the reference manual I get;
"Euphoria does not have pointers and does not need them." ? blink blink
I kinda like the fact that a number can be a value OR the pointer to a
value,
I even like assembly's 0100h or [0100h].
Can I PEEK a pointer? i = peek(A) .A is a linear address or seg:reg type?
I just have a problem with basic's use of peek , maybe this one is better.
Anyone upto speed on using peek ? help... (yet another learning curve)
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu