Re: Namespace clobbering internals

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

Jeremy Cowgar wrote:
> 
> Would it make sense that if a function/variable is called with no namespace
> qualifier that exists as a built-in and user defined inside a namespace
> that the built-in be used? That would seem like the logical answer.
> 
> The user knew there would be a conflict, thus, he/she included the file
> w/the conflict with a namespace to prevent that conflict.
> 
> Now. If you include a file w/no namespace and now you have a built-in and
> user defined function of the same name, no namespace qualifier and called
> it with no namespace qualifier, then I would think the application should
> err out as it does now.

This will break code.  One of my favorite things to do is to overload things
like print.  Of course, that could be fixed by using namespaces, but it
sort of defeats the purpose of overriding something like this.  It can
make debugging easier by inserting an override that logs, or does something
different, or whatever.

Also, what if you want to use the overload in the same file as it is
declared?  I suppose you could have the file include itself, but as CChris
would certainly tell us, that would just be silly.  A better solution might
 be to reserve a namespace for built-ins.  Maybe something like, "eu".

So your example might become:
include pgsql.e as pg
  include mysql.e as my
  pg:close()    -- pgsql.e's close function
  my:close()    -- mysql.e's close function
  eu:close()    -- reserved built-in namespace, use the built-in
  close()       -- error, multiple definitions

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu