Re: Euphoria types of the POLL
This post seemed to have confused some people, I'll try to explain better, but
first please review my previous post here...
Hayden McKay wrote:
>
> I have another idea, not releated to the the question though.
> maybee rob should consider something like this:
> }}}
<eucode>
>
> -- define some standard euphoria types
>
> type myInteger (integer i) return integer (i) end type
> type myAtom (atom a) return atom (a) end type
> type mySequence (sequence s) return sequence(s) end type
>
> -- now here's the idea
>
> global record myArray -- create a namespace called myArray
>
> age as myInteger -- define some fields for da myArray
> name as mySequence
> other as myAtom
>
> end record
>
> -- now myArray could be accessed like this with full typecheck
>
> myArray:name = "Hayden" -- assign some variables
> myArray:age = 28
>
> ? myArray:name -- print them to screen
> ? myArray:age
>
> </eucode>
{{{
>
> footnotes:
> Labels defined inside the record should be private, that means that
> access to record variables like so would be illegal...
> }}}
<eucode>
>
> ? myArray[1] -- should generate an illegal error
> ? myArray[name] -- should generate an illegal error
>
> name = 1 -- generate 'name' not defined error
>
> </eucode>
{{{
Useing the above for a reference, the 'record' myArray is an 'object'
hence...
? myArray -- produces -> {28,"Hayden",1.1}
-- actualy, note that in the previous post myArray:myAtom has not been
-- defined so..
? myArray -- produces -> myArray:myAtom not defined error
are you following me here ?
further more, note that 'records' would be 'object'
hence...
global record myVar
junk as integer
end record
myVar:junk = 1
? myVar -- produces -> 1
-- variable myVar is an integer 'cause that's the only definition in
-- that record
-- however if we had...
global record myVar
junk as integer
this as integer
end record
-- then 'myVar' would be a sequence consisting of 2 intergers
myVar:junk = 1
myVar:this = 1
? myVar -- produces -> {1,1}
I hope this better explained my idea of linking types useing namespace
there would probably be a few hurdles trying to implement it, but it's
only an amusing idea
|
Not Categorized, Please Help
|
|