1. redefining built-in routines.

On Wednesday 27 June 2001 03:15, Derek Parnell wrote:
> > Jiri:
> >     1.  allow re-definition of not just the built-in routines, but
> >         also of all previous declarations, possibly even constants (I
> >         know, Rob, you will never agree...) with mere warning.
>
> Now this sounds like a great idea. Why should RDS be the only dispenser of
> wisdom. For example, I can imagine somebody inventing a better abort()
> routine and I just might like to use that - without - modifing any of my
> existing code or included library files.

and Irv replied:

>Strangely enough, Euphoria handles just such a thing with no problem:
>  Warning: Built-in abort() redefined
>   Press Enter...

Well how about that! I can't recall reading about this feature of Euphoria.
But I went back to the docs and found this...

"You can override the definition of these built-in routines by defining your
own routine with the same name. You will get a suppressible warning if you
do this."

Not only can you redefine them, but you can change the parameters required
too.

Thanks Irv.

Now if only we could get the routine_id() of a built-in. That would be
something, it really would be something - to quote Paul McCartney.

>Change that from a built-in command to one in an include, however:
>  test.exu:3
>  attempt to redefine wait_key
>  function wait_key()
>                  ^

As you say, strange indeed.

-----------
cheers,
Derek Parnell
Senior Design Engineer
Global Technology Australasia Ltd
dparnell at glotec.com.au

---------------------




confidential information intended solely for the use of the individual or
entity to whom they are addressed. If you are not the intended recipient of
this message you are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited. If you have
received this message in error please notify the sender immediately. Any
views expressed in this message are those of the individual sender and may
not necessarily reflect the views of Global Technology Australasia Limited.
>

new topic     » topic index » view message » categorize

2. Re: redefining built-in routines.

Hello everyone,

>On Wednesday 27 June 2001 03:15, Derek Parnell wrote:
> > > Jiri:
> > >     1.  allow re-definition of not just the built-in routines, but
> > >         also of all previous declarations, possibly even constants (I
> > >         know, Rob, you will never agree...) with mere warning.
> >
> > Now this sounds like a great idea. Why should RDS be the only dispenser 
>of
> > wisdom. For example, I can imagine somebody inventing a better abort()
> > routine and I just might like to use that - without - modifing any of my
> > existing code or included library files.

You can do that right now.  In fact, I did that (redefined abort()) in one 
of my programs a while back.  It is redefining routines in includes that is 
the problem.

>and Irv replied:
>
> >Strangely enough, Euphoria handles just such a thing with no problem:
> >  Warning: Built-in abort() redefined
> >   Press Enter...
>
>Well how about that! I can't recall reading about this feature of Euphoria.
>But I went back to the docs and found this...
>
>"You can override the definition of these built-in routines by defining 
>your
>own routine with the same name. You will get a suppressible warning if you
>do this."
>
>Not only can you redefine them, but you can change the parameters required
>too.

And if you redefine it with a different number of parameters, it would be 
nice if Euphoria could "overload" functions and procedures. By this I mean:

procedure abort(integer a, sequence s)  --redefint abort()
    puts(1, s)
    abort(a) --built in abort()
end procedure

abort(1, "an error has occured") -- redefined abort()

abort(0) -- built in abort()

...
end procedure

procedure proc1(atom a, atom b) --"overload" proc1
...
end procedure

proc1(1) --the first proc1()

proc1(1, 2) --the second proc1()

>Thanks Irv.
>
>Now if only we could get the routine_id() of a built-in. That would be
>something, it really would be something - to quote Paul McCartney.

What? so you can't get the routine_id() of a built-in?  I always assumed you 
could.  Euphoria should let you do that, I don't see any reason why not.

>
> >Change that from a built-in command to one in an include, however:
> >  test.exu:3
> >  attempt to redefine wait_key
> >  function wait_key()
> >                  ^
>
>As you say, strange indeed.

No, not strange at all.  This whole namespace issue is about not being able 
to redefine symbols defined earlier in the program.  If you could redefine 
them, there would hardly be a problem with namespaces.

Daryl van den Brink

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu