+1 I suggested a similar feature a few days ago privately, I called it GWT.isLiteral(), since the underlying check is if its an AST literal in the compiler, although in my example, you can't do value comparisons, just assertions on the literal. The value checks would be done via traditional operators.
On Mon, Apr 27, 2009 at 12:33 AM, Vitali Lovich <[email protected]> wrote: > Kinda like with GCC, allow detection of constant values (i.e. > __builtin_constant_p). This way, you could do something like > > void addParameter (HashMap h, int size, String key, Object value) > { > if (GWT.isConstantValue(h, null)) { > if (GWT.isConstantValue(size, 0)) > size = 10; > h = new HashMap(size); > } > h.put(key, value). > } > > & you could have the performance of > > void addParameter (HashMap h?, int size?, String key, Object value) > > as if you wrote overloaded methods without needing to write several > different methods that just supply default values back & forth. Sometimes, > it's also possible to use a better algorithm if parameters have a known > constant value. > > > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
