RE: Declaring a Function Before it is used
Derek Parnell wrote:
>
> From: "Mike Nelson"
<snip>
> > I would suggest "declare" as a new keyword, used as below:
> >
> > declare function foo(3) -- the digit is the number of parameters
> >
> > declare global procedure bar(0)
> >
IMO this isn't really much cleaner than the routine_id() way. And it
still matters where you put the declare.
<snip>
> So why bother? Either do the 'C' thing ...
>
> declare function foo(sequence , integer , integer)
>
> or don't have a 'declare' but have the interpreter keep a fix-up
> table during the (single) parse pass.
I like this idea better (the VB-ish, fix-up table).
<snip>
> One really annoying aspect of routine_id() is that it doesn't do
> forward referencing either. If it did, it would simplify libraries
> like Win32lib and Diamond. We could then test for the existance of
> user-written routines - in win32lib's case, I could test for
> routine names like "onPaint_MyWindow" etc.. so the user of the
> library didn't have to do a setHandler() at runtime.
This would be easier to implement (in fact, looking at the RDS source,
Rob has comments that make it clear that it was a conscious decision to
disallow run-time forward referencing, rather than a consequence of the
design), although I prefer having explicit event handling connections.
Of course, you'd have to keep setHandler() to allow for single handlers
for multiple events and controls.
Matt Lewis
|
Not Categorized, Please Help
|
|