1. Re: routine_id() - Suggestion
Hello!
Some ideas:
There are some additional problems with routine_id() too:
It forms sort of an introspective feature in the otherwise
non-introspective language of Eu: i e you specify the name of
a routine as a *string*.
This seems to hinder the optimisation (in f ex the coming Eu->C
compiler) of eliminating usused routines in a bound/compiled
.exe file. (Since you never know which routine-name-strings
the program can compose and pass to routine_id() at runtime
(See note at bottom of letter)).
Here's my suggestion of a replacement of routine_id() (which
function should be marked obsolete and omitted from, say,
Euphoria 5.0):
Routine-id-getting should be done by a special notation, and not
by a (sort of introspective) function-call. Example of notation
is
1.
@foo -- the routine-id-constant of the routine bar
-- (called by the call_proc() / call_func() routines
-- just like nowadays)
or, if Eu had had a united namespace between routines
and variables, perhaps just (like Carl White wrote a second
ago)
2.
foo -- called like this: foo()
-- this notation alternative suggests that an ordinary
-- routine notation actually is a declaration of a
-- constant routine-id
My suggestion is that the current restriction of getting
routine-ids is kept, i e the routine-id-constant of a routine can't
be used, or even referred to inside a routine-declaration until
after, in scope, the routine has been declared.
Instead, I, beeing a very unimportant and not even
registered yet Euphoria user, vote for forward declarations.
They are strictly unnecessary since the same technique as now can
be used (copying the routine-id to a variable). But (as a question
of taste) cleaner and simpler.
With notation no 2, an elegant alternative to ordinary forward
declaration seems possible, through these extensions that would
be useful also for other purposes:
I. Constants can (like perhaps also variables), but don't have
too, be assigned directly when declared. F ex
constant ZZT
. . .
ZZT = 3
II. "Anonymous routine-ids" can be created, like this:
integer f = function(args) end function
-> forward declaration like this:
constant foo
. . .
foo = function(args) . . .end function
Martin Nilsson
------------------------------------------------------------
Note at bottom:
well, the private routines of a file actually can be omitted,
provided all calls to routine_id() in this file are of
of this kind:
routine_id("literal string here")
i e where routine_id()-calls oblige to the same restrictions
as my suggested routine-id-constant above.
So my prefer for a special notation is really just ideological,
because routine_id() looks like an ordinary function but doesn't
behave exactly like one, in that it seems to be the only function
in the world that knows from where it was called, just like
Jiri Babor pointed out i e
function get_routine_id(sequence routine_name)
return routine_id(routine_name)
end function
get_routine_id(something) doesn't behave exactly like
routine_id(something), while for any other routine-pair
function foo(args) ... end function
function get_foo(args)
return foo(args)
end function
this would be the case.