www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Tuple assignment

Denis Koroskin Wrote:

 That's because Python is not a strictly typed language. With proper type  
 propagation compiler helps you writing code the way in meant to be. E.g.  
 the following:
 (a, b, c, d) = ('tuple', 'of', 'three')
 could be statically disabled, but there is nothing wrong with allowing it  
 either: d would be just a no-op, you will know it for sure the moment you  
 try using it.

Python has the special symbol "_" which is used exactly as a no-op (you could call it "foo" it you wanted, but "_" doesn't create new memory assignments) so you can expand arbitrary tuples without creating new symbols: a, b, c, _ = ('tuple', 'of', 'three') I like the proposal for D, but I fear it could be a source of bugs (you expect the tuple to expand to 4 values but silently is expanding to only 3, leaving the fourth unchangued).
Oct 07 2010