www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - new, pattern matching, scoping

reply bearophile <bearophileHUGS lycos.com> writes:
A nice article that shows why D may be better without the "new" statement (and
Python just uses () to instantiate, but D may need a finer control during
struct/object creation):
http://www.scs.stanford.edu/~dm/home/papers/c++-new.html


Pattern matching, like in Mathematica (very refined), OCaml (faster), Haskell
(simple), or OMeta (powerful) is probably useful inside D too, this is a page
from Haskell docs:
http://www.haskell.org/tutorial/patterns.html


With the closures of D 2.x, D may need to improve its scoping rules to
something more clean:
http://tratt.net/laurie/tech_articles/articles/designing_sane_scoping_rules

Bye,
bearophile
Mar 04 2008
next sibling parent renoX <renosky free.fr> writes:
bearophile Wrote:

 A nice article that shows why D may be better without the "new" statement (and
Python just uses () to instantiate, but D may need a finer control during
struct/object creation):
 http://www.scs.stanford.edu/~dm/home/papers/c++-new.html
Very interesting, thanks. You're right: D would be better to follow his advice (though I suspect that it may prove harder than it seems). [cut]
 With the closures of D 2.x, D may need to improve its scoping rules to
something more clean:
 http://tratt.net/laurie/tech_articles/articles/designing_sane_scoping_rules
Also interesting, although I think the way she oppose nonlocal and global is quite artificial, those are different scope with different usage, and I wasn't surprised at all by the way Python behave in her first example, even though I don't know much about Python. Thanks for these links. renoX
Mar 04 2008
prev sibling next sibling parent Sean Kelly <sean invisibleduck.org> writes:
== Quote from bearophile (bearophileHUGS lycos.com)'s article
 A nice article that shows why D may be better without the "new" statement (and
Python just uses () to
instantiate, but D may need a finer control during struct/object creation):
 http://www.scs.stanford.edu/~dm/home/papers/c++-new.html
Interesting article, but I don't think that it applies to D because D contains no polymorphic value types, and thus the syntax for new/delete is consistent for all types in D. Still reading the other links. Sean
Mar 04 2008
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Interesting articles! First one was too long ;-P, but here are my 
thoughts on the others:

bearophile wrote:
 Pattern matching, like in Mathematica (very refined), OCaml (faster), Haskell
(simple), or OMeta (powerful) is probably useful inside D too, this is a page
from Haskell docs:
 http://www.haskell.org/tutorial/patterns.html
Well, I agree pattern matching is a useful construct. We already have some sort of "pattern matching" with template specialization. How exactly do you think this could be worked into D, however, since we don't have first-class tuples or dynamic typing?
 With the closures of D 2.x, D may need to improve its scoping rules to
something more clean:
 http://tratt.net/laurie/tech_articles/articles/designing_sane_scoping_rules
D doesn't have implicit variable declaration, so this isn't as much of an issue. IMO, marking every other variable I reference (i.e. member variables in classes enclosing methods, etc.), would just be too much work.
Mar 04 2008