[Laszlo-dev] Class static blocks

P T Withington ptw at pobox.com
Mon Apr 21 07:20:40 PDT 2008


Yeah, just trying to be forward-looking.

On 2008-04-21, at 09:55 EDT, Donald Anderson wrote:

> Right now we don't support static blocks, but if someone needs
> that effect, they can code a static function and call it in a static  
> initializer:
>
>  static var foo = pseudoStaticBlock();
>
> I can certainly put it on the list though...
>
> On Apr 21, 2008, at 9:30 AM, P T Withington wrote:
>
>> We ought to update our code and parser to follow this.
>>
>> Begin forwarded message:
>>
>>> From: "Lars Hansen" <lhansen at adobe.com>
>>> Date: 21 April 2008 00:40:09 EDT
>>> To: "Michael O'Brien" <mob at mbedthis.com>, "Jeff Dyer" <jodyer at adobe.com 
>>> >
>>> Cc: es4-discuss Discuss <es4-discuss at mozilla.org>
>>> Subject: RE: Class static blocks
>>>
>>> Static blocks are anonymous parameterless functions.  "var" hoists
>>> to the top of these functions (as in any other functions); "static"
>>> is disallowed (because it's legal only on class attributes); and
>>> other binding forms that are legal in functions ("function", "let",
>>> "const") are legal.
>>>
>>> --lars
>>>
>>>> -----Original Message-----
>>>> From: es4-discuss-bounces at mozilla.org
>>>> [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Michael  
>>>> O'Brien
>>>> Sent: 20. april 2008 22:16
>>>> To: Jeff Dyer
>>>> Cc: es4-discuss Discuss
>>>> Subject: Re: Class static blocks
>>>>
>>>> Jeff,
>>>>
>>>> What happens to "var" declarations inside a static block?
>>>> Are they converted to static declarations or disallowed?
>>>>
>>>> Similarly, I presume a redundant "static" attribute inside a
>>>> static block is allowed.
>>>>
>>>> Michael
>>>>
>>>>
>>>> On Apr 20, 2008, at 4:50 PM, Jeff Dyer wrote:
>>>>>
>>>>>
>>>>>
>>>>> On 4/20/08 11:52 AM, Michael O'Brien wrote:
>>>>>
>>>>>> I wanted to clarify the meaning of a static block. Consider:
>>>>>>
>>>>>> class Shape {
>>>>>>
>>>>>> static var count
>>>>>> var origin
>>>>>>
>>>>>> static {
>>>>>> // Is this static initialization code?
>>>>>>
>>>>>> count = 1
>>>>>> }
>>>>>>
>>>>>> {
>>>>>>
>>>>>> // Is this instance initialization code?
>>>>>>
>>>>>> origin = 0
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Reading the latest draft of the grammar I'm assuming that you  
>>>>>> must
>>>>>> now put static init code inside a static {} block. Is this  
>>>>>> correct?
>>>>>
>>>>> That is correct.
>>>>>
>>>>>> Does that mean that other directives outside of methods and  
>>>>>> static
>>>>>> blocks are instance initialization code?
>>>>>
>>>>> No, statements are no longer allowed at the top level of a class
>>>>> definition.
>>>>> Class initialization code goes in 'static {...}' blocks,
>>>> and instance
>>>>> initialization code goes in constructors, of course.
>>>> Multiple 'static
>>>>> {...}'
>>>>> blocks are allowed.
>>>>>
>>>>> Jd
>>>>>
>>>>
>>>> _______________________________________________
>>>> Es4-discuss mailing list
>>>> Es4-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es4-discuss
>>>>
>>> _______________________________________________
>>> Es4-discuss mailing list
>>> Es4-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es4-discuss
>>
>
>
> --
>
> Don Anderson
> Java/C/C++, Berkeley DB, systems consultant
>
> voice: 617-547-7881
> email: dda at ddanderson.com
> www: http://www.ddanderson.com
>
>
>
>



More information about the Laszlo-dev mailing list