Phobos packages a bit confusing

retard re at tard.com.invalid
Tue Dec 1 23:48:28 PST 2009


Wed, 02 Dec 2009 08:38:29 +0100, Pelle Månsson wrote:

> retard wrote:
>> Tue, 01 Dec 2009 18:58:25 -0500, bearophile wrote:
>> 
>>> Rainer Deyke:
>>>> "open" by itself is ambiguous.  What are you opening?  A window?  A
>>>> network port?  I think the word "file" needs to be in there somewhere
>>>> to disambiguate.
>>> When you program in Python you remember that open is a built-in
>>> function to open files :-) When you want to open other things you
>>> import other names from some module. So this ambiguity usually doesn't
>>> introduce bugs. It' a well known convention. Few well chosen
>>> conventions (sensible defaults) save you from a lot of useless coding.
>> 
>> These default values are sometimes very annoying. For instance almost
>> in every game you have a game object hierarchy and the super class of
>> game objects usually conflicts with built-in 'Object'. If I write an
>> adventure game and some event opens a dungeon door, open() suddenly
>> deals with files. Also IIRC Python has built-in print() command. What
>> if I want to redefine this to mean printing to a graphical quake like
>> game console.
>> 
>> Namespaces in general seem rather useful. I hate the php like 'there's
>> a flat global scope and everything is a free function approach'. It's
>> annoying me each time I use phobos.
> 
> door.open() ? In python, you can just override what open does if you
> need open(door).

In internal class methods the door.open can be written as this.open() or 
just open(). In that case you need to worry about other symbols, if they 
are globally available built-ins.



More information about the Digitalmars-d mailing list