On Tuesday 05 May 2009 20:42:06 Hoyt Koepke wrote:
> > it is a bit disturbing though:
> >  auto foo = Bar !(3, Baz, 42);
> >  auto bar = Foo !(z);
> >
> > it is hard to not think of these statements as negating something
> > (probably especially the second one ?)
> >  I wish D had chosen @ or $ instead of !.
>
> Perhaps, but isn't it true that every language has slightly confusing
> stuff when first considered?  Whitespace in python, < > for template
> stuff in C++, [] notation for buffers in cython (I've gotten used to
> it fine, and don't mind it now, but it did make me to do a few
> double-takes at first).   What I like about D's syntax is that it's
> easy to pick out !( ) as type arguments to a function, class, method,
> etc. and ( ) for the regular arguments.  What I have found to be nice
> (and granted, I haven't done much D programming recently) is that type
> parameters and regular parameters follow similar syntax, by intention.
>  I've found that templating stuff in D is an amazingly nice experience
> (C++ just stinks in comparison) as once I've got my head around what
> can and can't be done, the syntax is very intuitive.

in fact, I am not really sure I am buying that this:
 auto foo = Foo !(T1, T2, T3)(arg1, arg2);

is really cleaner/clearer than:
 auto foo = Foo (T1, T2, T3)(arg1, arg2);

that is what we do in python/PyROOT (the main python-to-C/C++ module we use in 
my field (High Energy Physics)):
 import ROOT
 cls =ROOT.std.vector(double) # instantiates std::vector<double>
 data = cls()
 assert hasattr(data, 'size')

 my_data = ROOT.std.vector('MyNS::MyClass')()
 my_data.push_back(...)
 assert isinstance(my_data[0], ROOT.MyNS.MyClass)

ROOT.std.vector being just a function returning classes, by type or by (C++) 
class name...

cheers,
sebastien.
-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to