Re: type checking ?

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

Matt Lewis wrote:
> 
> Bernie Ryan wrote:
> > 
> > Suppose you have a function/procedure and one of its
> > parameters is a sequence.
> > 
> > How can you type check the parameter to be a CONSTANT SEQUENCE NAME.
> 
> Could you elaborate on what you mean by "CONSTANT SEQUENCE NAME?" This
> sounds like you want the parameter to be a specific value.  If this is
> accurate, then I can't see the utility of this, but here's an example:
> }}}
<eucode>
> with type_check
> type my_constant_sequence_name( object m )
>     return equal( m, "My Constant Sequence Name" )
> end type
> 
> procedure foo( my_constant_sequence_name bar )
>     -- ...
> end procedure
> foo("My Constant Sequence Name")  -- works
> foo("Ha Ha!")                     -- fails
> </eucode>
{{{

> 

Matt:

constant
  MySEQ = {1,2,3,4,5,6,7,8,9}

procedure useit(sequence seq_name)
  -- do stuff.
end procedure

-- The user can enter this which is WRONG
useit("MySEQ")

-- Or the user can enter this is CORRECT
useit(MySEQ)

-- NOTE they are both sequences so procedure will accept either.

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

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

Search



Quick Links

User menu

Not signed in.

Misc Menu