Re: win32lib event handling question

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

ags wrote:
> 
> Jason Gade wrote:
> > >>Anyway, of course moving the procedure declaration above the routine_id
> > >>examining it works very well.
> > > 
> > > Welcome to my nightmare blink
> > > 
> > 
> > Yes, let's repeat again:  routine_id() is already a way to get around 
> > the normal calling mechanism and should allow forward referencing. 
> > Lather, rinse, repeat.
> 
> Maybe.  I'm too new to all this to have and informed opinion.  But when I 
> started using global atoms for routine_ids I realised that it makes it
> very easy to replace a routine referenced by a routine_id.

[snipped: a good example]

RDS has the programming philosophy that items ought to be declared earlier in
source code than their first reference.

This philosophy was implemented strictly in earlier versions of Euphoria. Later
it became apparent that one circumstance needed special treatment. This was the
circumstance where two routines referred to each other. Obviously, the first
routine couldn't reference the second one because it occured further on down in
the source code. Thus the 'routine_id()' was born. However, it also strictly
adheres to the philosophy in that a routine_id cannot refer to a routine that
exists further down in the source code. To use it to allow two routines to call
each other, the coder must create a variable that must be placed prior to both
routines, so that both routines can refer to it, and execute one or more
routine_id() calls before the two routines in question are called.

integer rid_one
integer rid_two
. . .
procedure one()
. . .
    call_proc(rid_two)
. . .
end procedure

procedure two()
. . .
    call_proc(rid_one)
. . .
end procedure

rid_one = routine_id("one")
rid_two = routine_id("two")


The routine_id() technique was created to solve a special, and rare, situation.
However, it has been used as a solution to many other smaller issues with the
language. Your example is one very valid reason to use it. Win32lib uses it in
two main ways; to assign a potential routine to an action, and to avoid the need
to keep shuffling code around when enhancements bump up against the physical
relationship philosophy between call and declaration. And a lot of people use it
for other reasonable purposes to.

When v2.5 alpha was released, RDS made a 'mistake'. They allowed routine_id() to
reference routines that were further down in the code. So this proved that there
was no technical reason for its documented behavior. Once people realized that
this was possible, we rejoiced because it granted us some long hoped for freedom
and improvement in code clarity. However, RDS corrected this mistake and returned
us to their vision of proper coding.

My argument now is that we should compromise. As routine_id() is a special usage
technique, and not one used in common code, it should be allowed to reference
routines further down in the source code, but direct references should still
stick with the RDS philosophy. People who are coding are smart enough to not be
confused by this.

The gain in code clarity and lowered maintence cost would easily offset the
perceived wrongness in forward referencing.

But I really don't expect RDS to do anything at all, so I don't know why I
bother.

-- 
Derek Parnell
Melbourne, Australia
Skype name:  derek.j.parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu