Bug 471378 - Property-style methods
Summary: Property-style methods
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Golo (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2015-06-29 16:25 EDT by Julien Ponge CLA
Modified: 2016-05-25 10:27 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Ponge CLA 2015-06-29 16:25:11 EDT
Golo currently does no magic on method resolution.

We could offer a shorter property-style method syntax such that:

foo: getBar(): getBaz(): setThat(123)

could be written as:

foo: bar: baz: that(123)

---- Artpej commented on 7 Nov 2014

:+1: great idea

maybe more like this :

foo: bar(): baz(): that(123)

like Dynamic Objects

----  yloiseau commented on 7 Nov 2014

You mean when using Java object providing get/set methods? Seems good to me.

:+1: for @artpej to keep consistency with DynamicObject and struct

----  yloiseau commented on 7 Nov 2014

Btw such code is a message chain smell (see law of Demeter) :smile:

----  jponge commented on 9 Nov 2014

Agree with Sylvain on keeping the parens.

----  yloiseau commented on 6 Dec 2014

It would be great to have this in 1.2, if time allows it... (but winter is coming...)

----  jponge commented on 8 Dec 2014

No need to rush, this can wait for 1.3 or 2.0 (depending on how we will schedule releases)

----  yloiseau commented on 9 Dec 2014

The comment was mainly for the joke

----  Artpej commented on 9 Dec 2014

It could be fun to expose java setters as with the builder pattern when it is possible (if the setter returns void):

public class MyPojo {

  private String firstName;
  private String lastName;

  public void setFirstName(String name) {
    this.firstname = name;
  }

  public void setLastName(String name) {
    this.lastName = name;
  }
}

could be used like this :

let pojo = MyPojo(): firstName("John"): lastName("Doe")

What do you think?

(Personnal reminder : a getter on a primitive boolean value is often exposed with the prefix is (isValid() instead of getValid())

----  yloiseau commented on 9 Dec 2014

:+1:

----  k33g commented on 9 Dec 2014

+1

----  jponge commented on 9 Dec 2014

It's not too hard to hack with method handles.