[Xtend Programming Language] conditional save navigation

25 views
Skip to first unread message

Mike Rumpf

unread,
Oct 13, 2016, 4:40:24 AM10/13/16
to Xtend Programming Language

Hello Xtend users and developers.


I use Xtend to enrich EMF models with additional functionality. That’s a typical use case for Xtend I believe. I also like the save navigation and elvis operator for dealing with optional references and attributes within the model. Following an optional feature I use save navigation (e.g. "anObject?.optionalFeature" and following an mandatory feature I use simple navigation (e.g. "anObject.mandatoryFeature"). I use simple navigation to reveal missing values, so I don’t want to use save navigation on spec. I am aware that this idea mixes the aspects logic and validation, but I want the logic to be robust and able to process invalid models as much as possible.


Do you have an idea how to decide between the two cases "optional" and "mandatory" programmatically? Perhaps it’s possible to introduce a new operator which behaves like "?." or "." depending on the information for the lower bound of the navigated feature within the EMF model. I already tried to analyze the information of a thrown null pointer exception but found not enough information to trace the model feature.


Sven Efftinge (sven@efftinge.de)

unread,
Oct 16, 2016, 8:54:00 AM10/16/16
to xtend...@googlegroups.com
I think it should be clearly signaled whether something can evaluate to null or not, so I recommend to use the explicit ?. operator. 
Ideally the compiler should complain if you use '.' on a nullable, but we don't have that analysis yet.

Sven

--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xtend-lang+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages