Bartosz Milewski Missing post

Jason House jason.james.house at gmail.com
Wed May 27 15:59:08 PDT 2009


Tim Matthews Wrote:

> 
> This may seem slightly OT but in your blog "I will use syntax similar to 
> that of the D programming language, but C++ and Java programmers 
> shouldn’t have problems following it."
> 
> 
> class MVar<T> {
> private:
>      T    _msg;
>      bool _full;
> public:
>      // put: asynchronous (non-blocking)
>      // Precondition: MVar must be empty
>      void put(T msg) {
>          assert (!_full);
>          _msg := msg; // move
>          _full = true;
>          notify();
>      }
>      // take: If empty, blocks until full.
>      // Removes the message and switches state to empty
>      T take() {
>          while (!_full)
>              wait();
>          _full = false;
>          return := _msg;
>      }
> }
> auto mVar = new MVar<owner::self, int>;
> 
> Why not MVar!(owner::self, int)? Why go back to ambiguous templates? 
> Apart from the move operator it looks like c++ to me. Sorry if this 
> doesn't make sense but I've missed a few previous posts.

Don't read into it. I took it as being more readable for non-D users. Angle brackets show up in C++ templates, Java generics, and C# generics. IMHO, <> is more recognizable, even for those that don't code in any of the languages mentioned. D's syntax is good, just not wide spread. 

Notice the lack of a template<typename T> that's required for C++, instead, the template argument is after the class name. There's also no constrictor or initializers which would be bugs in C++. It still looks like tweaked D code.



More information about the Digitalmars-d mailing list