add support for "shorthand" static constructor

Description

Lucee should support this code

component { static test=1; // executed when the class is loaded } ``` that works the same way as ``` #!javascript component { static {test=1;} // executed when the class is loaded } ``` but not the same way as the following ``` #!javascript component { static.test=1; // executed when the instance is loaded }

With that we should raise the question, if this is more confusing for the average developer than helpful.

Activity

Show:

Igal Sapir 7 November 2016 at 02:07

IMO the current implementation is correct and this ticket should be rejected.

Michael Offner 14 April 2015 at 13:08

this was the essence from this ticket
https://bitbucket.org/lucee/lucee/issue/268/static-keyword-doesnt-work-for-variables

because we closed that ticket i raised that ticket to make sure this info get not lost.

we will do a blog post with a detailed explanation of the benefits of the static scope in the future...

Michael Offner 14 April 2015 at 13:03

Ryan Guill 14 April 2015 at 12:49

> With that we should raise the question, if this is more confusing for the average developer than helpful.

Of course it is. I had to read it several times before I saw this difference. It will be more confusing for the experienced developer who has never seen this syntax before, and the one who has read this and forgotten that theres a difference.

> The average developer won't be using this sort of stuff, so you don't need to worry about them.

Even if you're right that the average developer wont be writing this code themselves, average and beginner developers will be the ones maintaining the code written by the "Experts". You do have to worry about them. You also have to worry about the ones who think they are experts.

Playing where's waldo with a full stop while trying to figure out why your code isn't working the way you expect when you are following a tutorial you found somewhere isn't my idea of a good time - or a "game lifting" endeavor.

I'm not clear on what you are trying to solve with these static features in general, much less this proposed syntax. (I believe adam and I disagree about its benefits and purpose for instance) Perhaps some use cases on what youre after would help us better assess what you've come up with and offer alternatives?

Michael Offner 14 April 2015 at 08:05

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Priority

Created 14 April 2015 at 07:48
Updated 5 May 2023 at 09:40

Flag notifications