PROPOSAL: Auto-assignment Parameters

Marek Kozieł develop4lasu at gmail.com
Fri Mar 27 15:20:01 PDT 2009


2009/3/27 Mark Mahieu <markmahieu at googlemail.com>:
> On 27 Mar 2009, at 00:22, Marek Kozieł wrote:
>
> We can also consider:
>   {
>      private String name;
>      public this setName (String this.name){};
>      public this.name String getName(){};
>    }
> While we have quite similar idea, they work really great with each
> other. I just still wander if that should go so far.
>
> I think you're right to question whether this would be going too far.
>  Looking at the getter method, I don't see a clear gain over the way it
> would currently be written, ie,
> public this.name String getName() {}
> doesn't strike me as a definite improvement on:
> public String getName() { return name; }
>
> So far, the only extension to the proposal which looks like it might be
> reasonable, is simply to allow it for method parameters in general.  I'm not
> convinced that it would be worthwhile, but for the sake of illustration
> here's the example again if that option were taken:
> private String name;
> public void setName(String this.name) {}
> public String getName() { return name; }
>
> In this variation, the method name, field, and type are each mentioned once
> for the getter, and once for the setter, with no need to mention extra
> variables.  Improving on that would almost certainly require language
> support for properties in general, which isn't what this proposal is about
> (and isn't in scope for Coin).
> Thanks for sharing your thoughts.
> Regards,
> Mark
>

I was thinking about that and found few conclusions about syntax:
    [returned field] returnedType methodName (Type assignedField, ...);


MAJOR DISADVANTAGE:
   We have few ways to obtain same target.


ADVANTAGE(s):
  (input) decreased a number of variables.
  (return) if  we have 5 return statement in method's body, we do not
have to write "return this.SomeVariable" 5 times, and this is good. We
have to notice that value is returned once while we might be forced to
write it 5 / 10 / 15 ... times.


INTERACTIONS:
 public this.name String getName(){
    if ( name==null ) return;
    synchronized (some){
       //determine name operations
       return;
    }
    // other operations ...
 };

Let's focus on second return statement.
Return need to be executed in synchronized block to prevent unexpected events.



-- 
Pozdrowionka. / Regards.
Lasu aka Marek Kozieł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list