Re: type checking ?

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

Bernie Ryan wrote:
> 
> Derek Parnell wrote:
> > 
> > Bernie Ryan wrote:
> > > The useit() procedure will try to process the sequence weather it is
> > > a constant name sequence or the actual constant sequence because they
> > > depending how the user calls the procedure.
> > > I do not know in advance what the constant sequence will be because it is
> > > added by the user via include file. 
> > > Of course if user passes the name as a sequence the procedure will crash. 
> > > I will just have to spell it out in the users manual and
> > > HOPE that they read it. 
> > 
> > 
> > I'm still trying to work out Bernie's issue but here's what I've got so
> > far...
> > 
> > Bernie has a file that is something like this ...
> > 
> > ------------ start of bernie's file
> > include userfileA.e
> > 
> > global function/procedure useit(sequence x)
> >  <some processing goes here>
> > end function/procedure
> > 
> > include userfileB.e
> > ------------- end of file
> > 
> > And a user of Bernie's application must supply a couple of include files.
> > 
> > ------ start of userfileA.e
> > global constant WhatEver = "some text"
> > ------ end of  userfileA.e
> > 
> > ------ start of userfileB.e
> > useit(WhatEver)
> > ------ end of  userfileB.e
> > 
> > Now the problem is that Bernie want to make sure that in userfileB, the user
> > codes ...
> > 
> >    useit(WhatEver)
> > 
> > and never codes ...
> > 
> >    useit("WhatEver")
> > 
> 
> Derek:
> 
>    Thanks for explaining it.
> 
>    That is exactly what I mean.
> 
>    How can you be sure that a user enters the token WhatEver which
> 
>    represents a string constant and not the string "WhatEver"
> 
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

Only the parser will have this info when it processes calls to useit().
Some possibilities I can think of:
1/ define a list of identifiers user is supposed to type. Then useit() will look
its argument up in that table and substitute the right value if the name was
found. Emit a warning in that event as seen fit.
2/ Shroud user code and check the IL for a call to oseit() using a named symbol
rather than a manifest string constant. Tougher, of course. And if user codes
constant myString="WhatEver"
useit(myString)

this approach won't work.
It all depends on what level of safety you want/need. The more, the more
expensive.

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu