Question regarding the syntax of "is"

57 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Fredo Erxleben

nieprzeczytany,
30 paź 2015, 05:54:1830.10.2015
do ceylon-dev
Hello there!

First, congratulations on the release of version 1.2

I have been following the development of the language and its features for a moment, and there is a little thing that bugs me:

Why is the syntax for the type checking
  
is (type name) (variable name)

?

Wouldn't it be far more readable to have an infix operator like

(variable name) is (type name)

, especially in combinations with assertions or assignments?

Disclaimer: I am aware that this is linguistic nit-picking and that there are quite good reasons for how things are… I merely have not found a satisfying answer for myself.

Tom Bentley

nieprzeczytany,
30 paź 2015, 06:02:3130.10.2015
do ceylon-dev

--
You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+...@googlegroups.com.
To post to this group, send email to ceylo...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/ecff87c6-5725-4e36-9738-0d85b534ec3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lucas Werkmeister

nieprzeczytany,
30 paź 2015, 12:31:4930.10.2015
do ceylo...@googlegroups.com
However, that page doesn’t mention that `variable is Type` is actually legal syntax. The difference is that the postfix form is a regular expression which doesn’t narrow the type while the prefix form is a *condition* (not an expression by itself) which does narrow the type.

Fredo Erxleben

nieprzeczytany,
4 lis 2015, 06:40:194.11.2015
do ceylon-dev
This indeed was my issue.

I so far never thought about this kind of mixing expressions, since I find them terribly unreadable.
Also I would rather write
!(is Person mike)
// or, in the unsupported syntax:
!(mike is Person)
and introduce parenthesis for readability. I am aware you can't enforce this though. And introducing the keyword isnot wouldn't probably be the best way either.

Well, I suppose I will have to live with this kind of syntax and ignore my grammar sense tingling all the time :)

But thanks for the clarification.
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0