|
Re: JvmField expression initializer generates function application [message #1245217 is a reply to message #1245098] |
Thu, 13 February 2014 13:21 |
|
On 13/02/2014 10:32, Hallvard Trætteberg wrote:
> Hi,
>
> I have a DSL based on Xbase from which I infer a JvmModel including som
> fields. I use the toField method and set the initializer to an
> expression. Suppose the field is of type Person, the name is hallvard
> and the XExpression is new Person("Hallvard", 'M'). The following is
> then generated:
>
> private Person hallvard = new Function0<Person>() {
> public Person apply() {
> Person _person = new Person("Hallvard", 'M');
> return _person;
> }
> }.apply();
>
> I would expect a simple
> private Person hallvard = new Person("Hallvard", 'M')
> instead of the same expression wrapped in a function.
>
> Since the generated code will be read by humans (students), I would
> prefer the simple variant. In what cases does the generator use this
> complex form and what can I do to help it simplify it?
IIRC this has been implemented as you would expect in latest versions
(at least in 2.5.1), but I cannot test it right now...
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Powered by
FUDForum. Page generated in 0.05021 seconds