Re: Namespaces?

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

Jeremy Cowgar wrote:
> 
> Shawn Pringle wrote:
> > I know some of the keywords will improve the experience of EUPHORIA but
> > changing namespace behavior so that you can use builtin names without
> > overriding must be too difficult for those who are getting into the
> > interpreter guts to do or we would have seen it already. :)
> > 
> 
> It's actually already done. Matt changed ~8 lines of code to make this work.
> 
This was preferable state to me.  I was suggesting we could over and over again
the same routine names for things that are common to most classes libraries:
 a constructor called new(), a type function kind().  The benefit of this
is you do not have to reinvent and the user doesn't have to remember constructor
names.  

Naming to new() & kind() instead of the include name adds a kind of flexibility.

As an example:
One map may be implemented with a two-element sequence: one with the keys and
the other with the values in mapskv.e.  Another may be implemented as a sequence
of key,value pairs:  mapkvs.e.  You can use 
include mapkvs.e as Process_map_t

, and use
that for everything using kind() and new().  As long as these two libraries use
the same routine names you can drop in one for the other simply by changing
the include line to say:
include mapskv  as Process_map_t

.

So, I guess I want to say when you have two things that are different 
implementations of the same abstract thing, it is beneficial to use the same
routine names in both.  Ofcourse, you could name kind() as map() and new() as
new_map but I think using kind() and new() is more elegant.

Shawn Pringle

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

Search



Quick Links

User menu

Not signed in.

Misc Menu