[erlang-questions] Here's hoping we get frames or structs in 2009!

Masklinn <>
Mon Jan 12 17:12:29 CET 2009


On 12 Jan 2009, at 00:10 , James Hague wrote:
> The Python version is similarly clean:
>
>   dict(width=1280, height=1024, colors=65536)
>
Just an fyi, this is *not* the python literal syntax for dicts, which  
would be:

     {'width':1280, 'height':1024, 'colors':65536}

what you posted is the ability to use arbitrary keyword arguments in  
the dict constructor, it's fairly recent (Python 2.3) and while it's  
slightly shorter for dicts where keys are exclusively strings (2 less  
characters per key above 2 keys), it also has limitations:

* Keys have to be strings, python's dictionaries aren't actually  
limited to string indexing (using the literal syntax one can use e.g.  
integers, tuples or frozensets as keys)
* Python keywords can't be used as keys (so e.g. class, def, if, else,  
in, for, ... will generate a syntax error if you're not using the  
literal syntax)
* Much harder to statically analyze (even though the literal syntax  
kind-of loses this in Python 3.0 with dict comprehensions)



More information about the erlang-questions mailing list