Re: fundamental data types in Euphoria cf C/C++

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

On Tuesday 07 August 2001 22:12, Derek Parnell wrote:
<snip>

> type Address(object x)
>     if not sequence (x) then
>         return 0
>     end if
>     if length(x) != AddressLength then
>         return 0
>     end if
>     if not equal(x[aType], AddressType) then
>         return 0
>     end if
>     if not StringASCII(x[aBuilding]) then
>         return 0
>     end if
>     if not StringASCII(x[aStreet]) then
>         return 0
>     end if
>     if not StringASCII(x[aCity]) then
>         return 0
>     end if
>     if not StringASCII(x[aPostCode]) then
>         return 0
>     end if
>     if not StringASCII(x[aCountry]) then
>         return 0
>     end if
>     if not StringASCII(x[aState]) then
>         return 0
>     end if
>
>     return 1
> end type

<snipping resumes>

And, of course you should point out that this is of purely academic 
interest, since user-written (as well as built-in) type checking can 
only respond by either silently allowing a successful assignment, 
or ending the program.  Ending a program on a data input error 
went out of favor along with the card deck, so programmers must 
validate all input anyway. Once validated, there's little reason not 
to just store it all as an "object", and dispense with type checking.

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu