PROPOSAL: 'forget' keyword (beta)

Marek Kozieł develop4lasu at gmail.com
Fri Mar 27 07:02:34 PDT 2009


   I do not know if there is point to describe this proposal in
details, because it require to introduce new keyword which may be
impossible for project Coin scope.?

AUTHOR: Lasu aka Marek Kozieł

OVERVIEW

FEATURE SUMMARY:
'forget' keyword allows to erase variable from current context, or it
means that field should not be used.

MAJOR ADVANTAGE:
This change makes language be more WYSIWYG.

MAJOR BENEFIT(s):
- It makes people be able to erase 'variable' from current context,
while now it's:
 -> impossible for final variables (only by comments),
 -> impossible for arguments (for not final Object we can assign null),
 -> impossible for fields.
 -> local fields need more or 'less' artificial blocks (two lines
wasted and one indent level).
- Declaring that variable should not be used, or does not contain
valid information for this scope (at current time) will be possible.
- Code quality does not fall so drastically after we leave it,
comparing to '=null', 'only comments' or 'weird blocks'.


MAJOR DISADVANTAGE:
New keyword == Someone can have declared method/field/variable named 'forget'.

ALTERNATIVES:
It's already listed.

EXAMPLES

SIMPLE / ADVANCED EXAMPLE(s):
  public static void main(final String[] args) {
    System.out.println(Arrays.toString(args));
    forget args; // 'args' cannot be used anymore
    String[] args; // ignore/warning/error : unclear code
   ...
  }

public class Forget {

  private ArrayList<String> criticKeys;

  public void addKey(String newKey){
    forget this.criticKeys; // use synchronized method ONLY
    ... // validate
    ... // add
  }

}

DETAILS

SPECIFICATION:
...

COMPILATION:
...

TESTING:
It's the same as testing effects of exiting from the block for
variables. For fields, it's just an access control.

LIBRARY SUPPORT:
None.

REFLECTIVE APIS:
None.

OTHER CHANGES:
None.

MIGRATION:
-

COMPATIBILITY
New keyword can be problem. There is not other impact.

REFERENCES
http://lasu2string.blogspot.com/2009/03/forget-keyword-proposal_27.html

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

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list