View mode: basic / threaded / horizontal-split · Log in · Help
October 10, 2012
Re: Remus
On 2012-10-09 21:10, Namespace wrote:

> My next version will contain the elvis operator:
> [code]
> Foo obj = otherObj.get() ?: null;
> if otherObj.get() is _not_ null, it will assign to obj, otherwise obj
> will be assigned with null.
> [/code]

Will it support this syntax:

Foo obj;
obj ?= otherObj.get();

Will only assign to "obj" if it's null.

-- 
/Jacob Carlborg
October 10, 2012
Re: Remus
On Wednesday, 10 October 2012 at 07:06:54 UTC, Jacob Carlborg 
wrote:
> On 2012-10-09 21:10, Namespace wrote:
>
>> My next version will contain the elvis operator:
>> [code]
>> Foo obj = otherObj.get() ?: null;
>> if otherObj.get() is _not_ null, it will assign to obj, 
>> otherwise obj
>> will be assigned with null.
>> [/code]
>
> Will it support this syntax:
>
> Foo obj;
> obj ?= otherObj.get();
>
> Will only assign to "obj" if it's null.

You mean:
[code]
Foo obj;
if (obj is null) {
    obj = otherObj.get();
}
[/code]
?

Interesting point. Until now this isn't supported but I will 
think about it.
October 10, 2012
Re: Remus
On 2012-10-10 09:10, Namespace wrote:

> You mean:
> [code]
> Foo obj;
> if (obj is null) {
>      obj = otherObj.get();
> }
> [/code]
> ?
>
> Interesting point. Until now this isn't supported but I will think about
> it.

Exactly, most language supporting the elvis operator supports this form 
as well, both Ruby and CoffeeScript do.

-- 
/Jacob Carlborg
October 10, 2012
Re: Remus
Am 10.10.2012 07:32, schrieb Namespace:
> And you ask for what namespaces are usefull? Aren't you miss them? I do,
> and so I implement them. You can already write "namespaces" in D, but
> you must use a (mixin) template (so you have these ugly parents) and for
> using you have to write: alias tpl_nspace!().print print or directly:
> tpl_nspace!().print. And that's ugly (because of '!()') and annoying IMO.

No, I really don't miss namespaces and if I really needed one, I would 
use a struct.
October 10, 2012
Re: Remus
On Wednesday, 10 October 2012 at 15:19:22 UTC, David wrote:
> Am 10.10.2012 07:32, schrieb Namespace:
>> And you ask for what namespaces are usefull? Aren't you miss 
>> them? I do,
>> and so I implement them. You can already write "namespaces" in 
>> D, but
>> you must use a (mixin) template (so you have these ugly 
>> parents) and for
>> using you have to write: alias tpl_nspace!().print print or 
>> directly:
>> tpl_nspace!().print. And that's ugly (because of '!()') and 
>> annoying IMO.
>
> No, I really don't miss namespaces and if I really needed one, 
> I would use a struct.

Each to their own. ;) And: you can use Remus without using 
namespaces. So if you don't like one piece of Remus, don't use 
it. ;)
October 10, 2012
Re: Remus
On Wednesday, 10 October 2012 at 13:14:22 UTC, Jacob Carlborg 
wrote:
> On 2012-10-10 09:10, Namespace wrote:
>
>> You mean:
>> [code]
>> Foo obj;
>> if (obj is null) {
>>     obj = otherObj.get();
>> }
>> [/code]
>> ?
>>
>> Interesting point. Until now this isn't supported but I will 
>> think about
>> it.
>
> Exactly, most language supporting the elvis operator supports 
> this form as well, both Ruby and CoffeeScript do.

The evlis operator is the next i will implement.
So I will consider if something like this is necessary. :)
October 10, 2012
Re: Remus
David, el 10 de October a las 16:55 me escribiste:
> Am 10.10.2012 07:32, schrieb Namespace:
> >And you ask for what namespaces are usefull? Aren't you miss them? I do,
> >and so I implement them. You can already write "namespaces" in D, but
> >you must use a (mixin) template (so you have these ugly parents) and for
> >using you have to write: alias tpl_nspace!().print print or directly:
> >tpl_nspace!().print. And that's ugly (because of '!()') and annoying IMO.
>
> No, I really don't miss namespaces and if I really needed one, I
> would use a struct.

Or even better, just use static import.

--
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Sometimes you got to suffer a little in your youth to motivate you to
succeed later in life. Do you think if Bill Gates got laid in high
school, do you think there'd be a Microsoft? Of course not. You gotta
spend a lot of time stuffin your own locker with your underwear wedged
up your arse before you think "I'm gona take over the world with
computers! You'll see I'll show them."
October 28, 2012
Re: Remus
Version 1.1 is now available.
Alterations:
 -> Package import. I see in the forum a good solution for 
package imports and so I merged it with Remus.
Because of that you can write now: import package PACKAGE_NAME : 
MODULE1, MODULE2, ... ;
Short example: import package std : stdio, regex, array;

 -> improved not null references:
 - you can declare not null references now as Return Type (wasn't 
possible before)
 - detect reliable if a reference is assigned or not (and if not: 
throw an error)
 - delete the '@' operator: you now have the 'makeRef' function.
Short example for that:
[code]
void test(Foo& fr) { }

void main() {
    Foo f = new Foo();
    Foo& fr = f;

    test(fr);
    test(makeRef(f));
    test(makeRef(new Foo));
}
[/code]
As you can see: there is no need to declare a senseless reference 
variable for a function which takes only a reference: you can use 
makeRef. And as you can see also: makeRef works even fine with 
RValues.

 -> improved Elvis Operator. And new: short elvis operator.
Example:
Foo f[ = new Foo()];
// ...
f ?= new Foo(); -> this is converted to: f = (f ? f : new Foo());
October 29, 2012
Re: Remus
Not interested, huh? Funny, that I had not expected.
October 29, 2012
Re: Remus
Namespace:

> Not interested, huh? Funny, that I had not expected.

Maybe they appreciate more something that improves the life of 
regular D programmers. There are many possible ways to do that, 
like trying to design features that quite probably will be added 
to D, or trying library ideas that will become part of Phobos, 
trying new GC features, trying new Phobos modules, and so on and 
on.

Otherwise you risk creating another Delight 
(http://delight.sourceforge.net/ ) that no one uses, it's just a 
waste of time for you too.

Bye,
bearophile
1 2 3 4 5 6
Top | Discussion index | About this forum | D home