www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Ceylon language

reply bearophile <bearophileHUGS lycos.com> writes:
spir:

 But I guess optionality could, and should, extend to non-ref types; thus, null
 is just a particular case of non-existence. And this would apply especially on
 function parameters:
    void f (int i?) {...}

From C# experience it seems non-ref nullable types are not so useful (and it's not hard to implement them with the language itself).
 Also, they should reuse '?' to mean 'exists', possibly '!?' meaning the
opposite:
     void f (int i?) {
     if (? i) doWithI(i);
     if (!? i) doWithoutI();
     ...
 }

Better to keep the language less perlish.
 great! get rid of new in D as well

This was discussed a lot. I don't have much interest in this change.
 We may define a class method "by reference":

 void hello(String name) = hello;

???

The second hello is a function reference. Nothing so interesting to see here.
 I don't get the diff between currying & partial app.

Take a look at the wikipedia pages, the difference is small, they are quite related things, their difference is no so important: http://en.wikipedia.org/wiki/Currying http://en.wikipedia.org/wiki/Partial_application
 And find this feature much complication for close to uselessness.

In functional-style programming it's useful to be able to curry (or partially applicate) functions, it helps keep the code shorter and less noisy.
 examples?

See the first PDF at those pages. In the meantime people have mirrored those PDFs, see the Reddit thread.
 Yo; and while you're at "typestating", extend the feature to any type (not only
 pointers).

For this you may need to look for a language (Rust) designed for the ground up for this feature. Bye, bearophile
Apr 14 2011
next sibling parent reply spir <denis.spir gmail.com> writes:
On 04/14/2011 09:06 PM, bearophile wrote:
 But I guess optionality could, and should, extend to non-ref types; thus, null
  is just a particular case of non-existence. And this would apply especially on
  function parameters:
      void f (int i?) {...}



Dunno C# at all. But I find optionality far more useful for non-ref types, since in the general case there is no truelly special or invalid value like null. What value means undefined/inexistent/non-provided, for an int? a bool? Unlike for ref'ed types (actual pointers/classes/arrays) we simply cannot express this without language support. This also leads to actual distinction of null and [] or "" for arrays & strings. Just dreaming... Denis -- _________________ vita es estrany spir.wikidot.com
Apr 14 2011
parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
spir Wrote:

 This also leads to actual distinction of null and [] or "" for arrays & 
 strings. Just dreaming...

Really? You want this? I really like that a null array is equal to an empty array. If you really care to find out if a string is null if(str is null)
Apr 14 2011
parent reply "Nick Sabalausky" <a a.a> writes:
"Jesse Phillips" <jessekphillips+D gmail.com> wrote in message 
news:io7oov$21d8$1 digitalmars.com...
 spir Wrote:

 This also leads to actual distinction of null and [] or "" for arrays &
 strings. Just dreaming...

Really? You want this? I really like that a null array is equal to an empty array.

I've thought about that and I don't know how I feel about it. On one hand, I can certainly image cases where the distiction between null and empty would be useful. But OTOH, after having to put up with the nightmare of VB6's "One million distinct ways to have a string that doesn't contain anything", I'm hesitent at embracing extra ways to have "ain't nuthin' here".
Apr 14 2011
parent Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 I've thought about that and I don't know how I feel about it. On one hand, I 
 can certainly image cases where the distiction between null and empty would 
 be useful. But OTOH, after having to put up with the nightmare of VB6's "One 
 million distinct ways to have a string that doesn't contain anything", I'm 
 hesitent at embracing extra ways to have "ain't nuthin' here".
 

In our project we use if(string.IsNullOrEmpty(str)){...} almost everywhere only in two places null matters. T__T
Apr 14 2011
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:io7gk3$1jea$1 digitalmars.com...
 spir:

 But I guess optionality could, and should, extend to non-ref types; thus, 
 null
 is just a particular case of non-existence. And this would apply 
 especially on
 function parameters:
    void f (int i?) {...}

From C# experience it seems non-ref nullable types are not so useful (and it's not hard to implement them with the language itself).

My experience indicates it's hard to implement useful generics in C# at all. (Ex: Missing IArithmetic, anyone?)
Apr 14 2011