Re: Why Types?

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

On Wed, 13 Dec 2000 08:08:57 -0500, John wrote:

>From what I see ( I am very new to euphoria) anything that is a sequence
>can be an integer or string...?big question mark

A sequence contains objects, (which can be atoms, integers, or sequences).
If it contains integers that are printable ANSI characters, then you might
think of it as a string (even though it's just a sequence of numbers that
represent characters).

>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?

s=65 does not work if s is declared as a sequence because 65 is an atom
(more specifically, an integer)

likewise, s=(65) is the same as s=65 because (65)=65

but if you had said
s={65} (notice curley brackets, not parentheses) then you would *not* get
an error.
puts(1,s) would print the character 'A'

>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

not unless a65 is an already-defined variable or constant

>s=(A 65)    no

you aren't using the correct notation (parentheses instead of curley
brackets, and no commas separating elements)

if s is declared to be an object, then
s = {'A',65} would be OK. this is the same as s = {'A','A'} or s = {65,65}

>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)

s = {"A",65} would be OK this is the same as
s = {{'A'},65} which is the same as
s = {{65},65}


>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)

Yes, 'peek' is usually used to fetch data from a pointer when working with
C data structures.  There are plenty of examples of this usage in Win32Lib.

Hope I cleared up some data type confusion for you.

-- Brian

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

Search



Quick Links

User menu

Not signed in.

Misc Menu