Re: [Vala] Safe call operator

2012-02-20 Thread Jens Georg
On Mo, 2012-02-20 at 07:28 +0100, pancake wrote:
> i really like the idea of having the elvis operator and the safe navigation 
> operator in Vala.

Elvis is already supported, just with different syntax: ?? (same as in
C#)

> 
> fmi : http://groovy.codehaus.org/Operators
> 
> is this going to be added at some point into the compiler?
> 
> On Feb 1, 2012, at 21:08, Jim Nelson  wrote:
> 
> > I was going to mention that as well.  Null handling in Java is not
> > analogous to Vala's strategy, if for no other reason than there's no NPE.
> > 
> > It looks to me the idea of a future Vala that emphasizes code correctness
> > is that it will catch things like this:
> > 
> > Xyxxy? x = get_xyzzy();
> > int result = x.foo();
> > 
> > The compiler will flag that last line as problematic.  I think it will, at
> > least.  I don't really know.  But it seems to me that if null-checking is
> > going to be enforced by the compiler, it's not too much to ask the language
> > to supply good tools for doing that checking.  The nullable operator is one
> > step in that direction, but I've coded many lines where I needed something
> > like the Elvis operator (and the associated operators suggested by Project
> > Coin).
> > 
> > I'll also point out that (according to the Project Coin page) the reason
> > the null-safety operators were turned down by the Java committee was that
> > the Checker framework was added to Java and that Groovy, the inspiration
> > for the proposed syntax, uses dynamic typing, which makes the operators
> > more flexible.  But the first is not going to happen for Vala (I've not
> > heard of any such framework) and the second could be made to argue against
> > the nullable operator, which was, in fact, added to Vala.
> > 
> > I think the Elvis operator (and its cousins) should get real consideration
> > and not be dismissed merely because Java didn't take them.
> > 
> > -- Jim
> > 
> > 
> > 
> > On Tue, Jan 31, 2012 at 7:27 AM, Artem Tarasov 
> > wrote:
> > 
> >>> As a starter, Java rejected that syntax.
> >> 
> >> Yeah, but in Java at least a NullPointerException is thrown when null
> >> dereferencing occurs. In Vala the only option to provide null-safety
> >> is explicit checking for null after each method call in a chain.
> >> ___
> >> vala-list mailing list
> >> vala-list@gnome.org
> >> http://mail.gnome.org/mailman/listinfo/vala-list
> >> 
> > ___
> > vala-list mailing list
> > vala-list@gnome.org
> > http://mail.gnome.org/mailman/listinfo/vala-list
> ___
> vala-list mailing list
> vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list
> 


___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-02-19 Thread pancake
i really like the idea of having the elvis operator and the safe navigation 
operator in Vala.

fmi : http://groovy.codehaus.org/Operators

is this going to be added at some point into the compiler?

On Feb 1, 2012, at 21:08, Jim Nelson  wrote:

> I was going to mention that as well.  Null handling in Java is not
> analogous to Vala's strategy, if for no other reason than there's no NPE.
> 
> It looks to me the idea of a future Vala that emphasizes code correctness
> is that it will catch things like this:
> 
> Xyxxy? x = get_xyzzy();
> int result = x.foo();
> 
> The compiler will flag that last line as problematic.  I think it will, at
> least.  I don't really know.  But it seems to me that if null-checking is
> going to be enforced by the compiler, it's not too much to ask the language
> to supply good tools for doing that checking.  The nullable operator is one
> step in that direction, but I've coded many lines where I needed something
> like the Elvis operator (and the associated operators suggested by Project
> Coin).
> 
> I'll also point out that (according to the Project Coin page) the reason
> the null-safety operators were turned down by the Java committee was that
> the Checker framework was added to Java and that Groovy, the inspiration
> for the proposed syntax, uses dynamic typing, which makes the operators
> more flexible.  But the first is not going to happen for Vala (I've not
> heard of any such framework) and the second could be made to argue against
> the nullable operator, which was, in fact, added to Vala.
> 
> I think the Elvis operator (and its cousins) should get real consideration
> and not be dismissed merely because Java didn't take them.
> 
> -- Jim
> 
> 
> 
> On Tue, Jan 31, 2012 at 7:27 AM, Artem Tarasov 
> wrote:
> 
>>> As a starter, Java rejected that syntax.
>> 
>> Yeah, but in Java at least a NullPointerException is thrown when null
>> dereferencing occurs. In Vala the only option to provide null-safety
>> is explicit checking for null after each method call in a chain.
>> ___
>> vala-list mailing list
>> vala-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/vala-list
>> 
> ___
> vala-list mailing list
> vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-02-01 Thread Jim Nelson
I was going to mention that as well.  Null handling in Java is not
analogous to Vala's strategy, if for no other reason than there's no NPE.

It looks to me the idea of a future Vala that emphasizes code correctness
is that it will catch things like this:

Xyxxy? x = get_xyzzy();
int result = x.foo();

The compiler will flag that last line as problematic.  I think it will, at
least.  I don't really know.  But it seems to me that if null-checking is
going to be enforced by the compiler, it's not too much to ask the language
to supply good tools for doing that checking.  The nullable operator is one
step in that direction, but I've coded many lines where I needed something
like the Elvis operator (and the associated operators suggested by Project
Coin).

I'll also point out that (according to the Project Coin page) the reason
the null-safety operators were turned down by the Java committee was that
the Checker framework was added to Java and that Groovy, the inspiration
for the proposed syntax, uses dynamic typing, which makes the operators
more flexible.  But the first is not going to happen for Vala (I've not
heard of any such framework) and the second could be made to argue against
the nullable operator, which was, in fact, added to Vala.

I think the Elvis operator (and its cousins) should get real consideration
and not be dismissed merely because Java didn't take them.

-- Jim



On Tue, Jan 31, 2012 at 7:27 AM, Artem Tarasov wrote:

> > As a starter, Java rejected that syntax.
>
> Yeah, but in Java at least a NullPointerException is thrown when null
> dereferencing occurs. In Vala the only option to provide null-safety
> is explicit checking for null after each method call in a chain.
> ___
> vala-list mailing list
> vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-02-01 Thread PCMan
This can induce hard to debug errors.
For example, something should raise an error or an execption now may return
0 only.
This return value might accidentally be used by other parts of the program.
When the project become larger, it's hard to trace this bug.

On Tue, Jan 31, 2012 at 11:27 PM, Artem Tarasov
wrote:

> > As a starter, Java rejected that syntax.
>
> Yeah, but in Java at least a NullPointerException is thrown when null
> dereferencing occurs. In Vala the only option to provide null-safety
> is explicit checking for null after each method call in a chain.
> ___
> vala-list mailing list
> vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-01-31 Thread Artem Tarasov
> As a starter, Java rejected that syntax.

Yeah, but in Java at least a NullPointerException is thrown when null
dereferencing occurs. In Vala the only option to provide null-safety
is explicit checking for null after each method call in a chain.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-01-31 Thread Luca Bruno
On Tue, Jan 31, 2012 at 3:32 PM,  wrote:

> Do you know the reason why it was rejected?  I searched for more
> information but could only find the proposals, not the rejection.
>

http://blogs.oracle.com/darcy/entry/project_coin_final_five

-- 
www.debian.org - The Universal Operating System
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-01-31 Thread jim
Do you know the reason why it was rejected?  I searched for more information 
but could only find the proposals, not the rejection.

A null-safe operator (an "elvis" operator) seems like a natural complement to 
the nullable operator already in Vala.

-- Jim

On Tue, Jan 31, 2012 at 4:58 AM, Luca Bruno  wrote:
> On Tue, Jan 31, 2012 at 1:34 PM, Artem Tarasov 
> wrote:
> 
> > There's so-called 'safe call operator' in Kotlin programming language
> > which, when used in chains, resembles 'Maybe' monad from Haskell. Thus it
> > makes easier to work with nullable types in some cases. Is it possible to
> > add such a feature to Vala?
> >
> 
> Adding a feature is always possible, but it must be discussed first :-)
> As a starter, Java rejected that syntax.
> 
> -- 
> www.debian.org - The Universal Operating System
> 
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Safe call operator

2012-01-31 Thread Luca Bruno
On Tue, Jan 31, 2012 at 1:34 PM, Artem Tarasov wrote:

> There's so-called 'safe call operator' in Kotlin programming language
> which, when used in chains, resembles 'Maybe' monad from Haskell. Thus it
> makes easier to work with nullable types in some cases. Is it possible to
> add such a feature to Vala?
>

Adding a feature is always possible, but it must be discussed first :-)
As a starter, Java rejected that syntax.

-- 
www.debian.org - The Universal Operating System
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Safe call operator

2012-01-31 Thread Artem Tarasov
Hello, today I stumbled upon this page:
http://confluence.jetbrains.net/display/Kotlin/Null-safety

There's so-called 'safe call operator' in Kotlin programming language
which, when used in chains, resembles 'Maybe' monad from Haskell. Thus it
makes easier to work with nullable types in some cases. Is it possible to
add such a feature to Vala?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list