Cool, I had no idea GCC provided that information. I won't claim to be one
of the compiler gurus, but this sounds pretty feasible to me, and to Ray's
point, might be a useful way of loosening the GWT.create() magic a bit.

@Lex, Scott: What do you think? Is this relatively easy and useful?

On Mon, Apr 27, 2009 at 4:49 AM, Vitali Lovich <vlov...@gmail.com> wrote:

> Yeah, probably from a compiler's perspective, the value check may be more
> complicated (the value may only be available after the AST stage depending
> on when optimization is done)
>
> It can possibly bloat the resultant code (since I believe you may have to
> build different implementations of each function and you may get overhead,
> even if you inline).  However, I think this might be an OK tradeoff since
> the assumption would be that you are optimizing for speed as opposed to size
> if you use something like GWT.isLiteral.
>
>
> On Mon, Apr 27, 2009 at 3:45 AM, Ray Cromwell <cromwell...@gmail.com>wrote:
>
>>
>> +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 <vlov...@gmail.com>
>> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to