Question regarding the syntax of "is"

57 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

Fredo Erxleben

غير مقروءة،
30‏/10‏/2015، 5:54:18 ص30‏/10‏/2015
إلى 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

غير مقروءة،
30‏/10‏/2015، 6:02:31 ص30‏/10‏/2015
إلى 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

غير مقروءة،
30‏/10‏/2015، 12:31:49 م30‏/10‏/2015
إلى 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

غير مقروءة،
04‏/11‏/2015، 6:40:19 ص4‏/11‏/2015
إلى 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.
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة