package java.lang;
abstract class Math
{
static int max(int x, int y)
{
return x > y ? x : y;
}
...
}
You would write in Nice:
package nice.lang;
int max(int x, int y)
{
return x > y ? x : y;
}
package a;
class Color
{
static Color[] colors;
...
}
Nice code:
package a;
var Color[] colors;
class Color
{ ... }
One has to be aware that static variables have a great disadvantage: they do no play well with repetitive or concurrent uses of a library. Since libraries are often first written as a standalone program, this problem is often overthought. Later, the static variables have to be replaced with fields of a State object that is passed around. Therefore I think static variables should be seldom used. Now I wonder if language design can help discouraging their use. Should they be disallowed completely? Do some languages try to adress this issue?
-- DanielBonniot - 14 Jun 2002
| Topic StaticFieldsAndMethods . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More } |
|
Revision r1.2 - 11 Feb 2003 - 13:36 GMT - TWikiGuest Parents: WebHome > NiceTutorial |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |