component or class

117 views
Skip to first unread message

Michael Offner

unread,
Apr 23, 2015, 5:19:18 AM4/23/15
to lucee
ATM we still use the word "component" for components in the Lucee dialect, should we consider to use the term "class" instead in the Lucee dialect

so instead of
component {
}

we do 
class {
}

in our code. we could still support "component" as alias to make the conversion of an existing application easier. 


What do you think?
Micha

Adam Cameron

unread,
Apr 23, 2015, 5:30:38 AM4/23/15
to lu...@googlegroups.com
Agree. "class" is the ubiquitous OO term for these things. It wasn't so cool CFML called them component's from the outset.


I've lobbied in the past to get the term changed to "class" for CFML as well, but ppl recoiled in horror and didn't think it was a good use of Adobe's time. Mileage varies, it seems.

Good call, Micha.

-- 
Adam

Andrew Dixon

unread,
Apr 23, 2015, 5:46:02 AM4/23/15
to lu...@googlegroups.com
I would agree with class as well.

Kind regards,

Andrew
about.me
mso - Lucee - Member

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/5a87ea0b-79d8-4b51-b986-6dae02534d4e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

thorste...@googlemail.com

unread,
Apr 23, 2015, 5:53:57 AM4/23/15
to lu...@googlegroups.com
I vote for class.

Jonas Hauß

unread,
Apr 23, 2015, 5:56:49 AM4/23/15
to lu...@googlegroups.com

Kai Koenig

unread,
Apr 23, 2015, 5:59:11 AM4/23/15
to lu...@googlegroups.com
Yes, should be class in .lucee

Cheers
Kai


Jeroen Knoef

unread,
Apr 23, 2015, 7:08:47 AM4/23/15
to lu...@googlegroups.com
I would only like that with proper constructors. A discussion about constructors was started a while ago, including some proposals. The 'init' convention has served us well, but if something is going to be called a class, I think a proper constructor is required. If 'class' is just an alias for 'component', you might lose the opportunity to do something about this in the future.

Adam Chapman

unread,
Apr 23, 2015, 8:01:00 AM4/23/15
to lu...@googlegroups.com
+1 for class.. I always wondered why MM used the term "component"..

Jesse Shaffer

unread,
Apr 23, 2015, 8:06:46 AM4/23/15
to lu...@googlegroups.com

Gert Franz

unread,
Apr 23, 2015, 8:23:48 AM4/23/15
to lu...@googlegroups.com

+1 for me too… maybe we could think about a constructor keyword too?

 

Sincerely
Gert Franz

 

RASIA GmbH

Spittelgasse 7

5103 Moeriken-Wildegg

Email: ge...@rasia.ch
Skype: gert.franz

Phone Switzerland: +41 76 5680 231

image001.png

Jean Moniatte

unread,
Apr 23, 2015, 8:24:21 AM4/23/15
to lu...@googlegroups.com
If component becomes class, shouldn't function become method ?

Thanks,
Jean

On Thu, Apr 23, 2015 at 2:06 PM, Jesse Shaffer <dajest...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Simon Hooker

unread,
Apr 23, 2015, 8:24:51 AM4/23/15
to lu...@googlegroups.com
Definitely in favour of class

Michael Offner

unread,
Apr 23, 2015, 8:46:36 AM4/23/15
to lucee
@Jeroen
In the Lucee dialect the "init" method is always executed before you get access on the instance and it doesn't matter what the method return you always get the component, so it is like a real constructor. 
we will also discuss in the tech board to add support for listeners that you get access before the constructors are executed.

BTW the final decision about class/component will happen on the tech board.

Micha



On Thu, Apr 23, 2015 at 1:08 PM, Jeroen Knoef <jer...@neoneo.nl> wrote:
I would only like that with proper constructors. A discussion about constructors was started a while ago, including some proposals. The 'init' convention has served us well, but if something is going to be called a class, I think a proper constructor is required. If 'class' is just an alias for 'component', you might lose the opportunity to do something about this in the future.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Michael Offner

unread,
Apr 23, 2015, 8:52:14 AM4/23/15
to lucee
@adam
I think because you can access them from remote, so you could say it is more than just a class it is a component...
maybe Sean Corfield has some insight on this ...

Micha



--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Jeroen Knoef

unread,
Apr 23, 2015, 8:53:18 AM4/23/15
to lu...@googlegroups.com
Thanks, sounds good to me Micha.
 
we will also discuss in the tech board to add support for listeners that you get access before the constructors are executed.
What is the use case for this? Is this related to the earlier discussion about CreateObject()?

 

You received this message because you are subscribed to a topic in the Google Groups "Lucee" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lucee/MzOw82hnzEg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Tony Junkes

unread,
Apr 23, 2015, 8:57:50 AM4/23/15
to lu...@googlegroups.com
+1

Michael Offner

unread,
Apr 23, 2015, 8:58:54 AM4/23/15
to lucee
yes, the Lucee dialect does not support createObject what allowed to inject code after the body constructor was executed but before init was executed.
the idea is that you can do the following
ObjectNew(component:"Whatever",arguments:[],listener:function(component c){/* here you can manipulate the cfc before the constructors are executed*/})  (the final name of that function also get decided by the tech board).

Micha

Jesse Shaffer

unread,
Apr 23, 2015, 10:32:36 AM4/23/15
to lu...@googlegroups.com
TBH, I would prefer to get rid of the keyword altogether:

class {
   
public any myFunctionName() {

   
}
}

Adam Cameron

unread,
Apr 23, 2015, 10:42:35 AM4/23/15
to lu...@googlegroups.com
Agreed. What else could a construct

public any myFunctionName() {

}

possibly be, other than a function? It shouldn't need to be flagged as such.

-- 
Adam

Jeroen Knoef

unread,
Apr 23, 2015, 10:45:13 AM4/23/15
to lu...@googlegroups.com
+1 for that! (or +infinity if that helps)
 
The keyword is needed (I presume) because all modifiers are optional. You're allowed to write:
 
class {
 
function myFunctionName() {
 
}
 
}
 
Without the keyword, it would be harder for the parser to distinguish between a function declaration and a function call (in the pseudo-constructor). That could be mitigated if one of the modifiers is required, e.g. the return type. Or, the pseudo-constructor is dropped as well, in the Lucee dialect. In that case, there's never any executable code in the class declaration.
 
Many languages do have this keyword btw (Scala for instance has 'def').
 

 

You received this message because you are subscribed to a topic in the Google Groups "Lucee" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lucee/MzOw82hnzEg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Adam Cameron

unread,
Apr 23, 2015, 11:01:21 AM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 15:45:13 UTC+1, Jeroen Knoef wrote:
+1 for that! (or +infinity if that helps)
 
The keyword is needed (I presume) because all modifiers are optional. You're allowed to write:
 
class {
 
function myFunctionName() {
 
}
 
}
 
Without the keyword, it would be harder for the parser to distinguish between a function declaration and a function call (in the pseudo-constructor).


Declaration:
myFunction(){} 

Call:
myFunction()  

A function declaration must be followed by braces. A function call must not.

But, yes, I don't doubt it's harder. But I think the syntax is unambiguous.

Still: Micha or Igal would know better about that... they've often noticed edgecases where weirdo (but legit) code combinations can actually seem like other syntax constructs.

And also: it's not like it's a very exciting suggestion. But a suggestion nonetheless.


-- 
Adam

Michael Offner

unread,
Apr 23, 2015, 12:09:53 PM4/23/15
to lucee
what's about closures?
susi=function(){};

should we do this?
susi=(){};

this would raise the question if we should only support Lambda functions then (with closure enviroment)...

Micha


Jesse Shaffer

unread,
Apr 23, 2015, 12:13:13 PM4/23/15
to lu...@googlegroups.com
On Thursday, April 23, 2015 at 11:09:53 AM UTC-5, Micha wrote:
what's about closures?
susi=function(){};

should we do this?
susi=(){};

this would raise the question if we should only support Lambda functions then (with closure enviroment)...
Micha
 
I don't think what I suggested applies to lambdas/anonymous functions - we're only talking about member functions defined in the body of a class.  Outside of a class, then yes, you would need the function keyword.

Michael Offner

unread,
Apr 23, 2015, 12:24:24 PM4/23/15
to lucee
There is an other problem come to my mind with that for the parser, take this example:
mail(subject="sss",...){
}

this could be a tag invocation (ACF Style) or a function definition.
Of course we should think to get rid of one of the script tag syntaxes anyway in the Lucee dialect.

should the "function" keyword optional or not supported at all inside components?

Micha





--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Sean Corfield

unread,
Apr 23, 2015, 12:38:13 PM4/23/15
to lu...@googlegroups.com
On Apr 23, 2015, at 5:52 AM, Michael Offner <mic...@lucee.org> wrote:
I think because you can access them from remote, so you could say it is more than just a class it is a component...

First off it was Allaire’s folks who chose "component". The rewrite from C++ to Java was well underway by the time Macromedia acquired Allaire.

In the early versions of what became CFMX, components were a custom tag library so you wrote:

<cf:component>
<cf:function …>
</cf:function>
</cf:component>

Tightly coupled to this custom tag library was a Spectra-like persistence engine — which was dropped before the first alpha — so they were very much viewed as "components" rather than "classes". You simply couldn’t do real OOP with them and that didn’t seem to be how the Allaire team thought of them.

CFMX 6.1 made it possible to do "real" OOP with these "components" but by then the names were fixed and the golden calf of "backward compatibility" meant we’d never see them changed.

Fast forward over a decade and the world’s a very different place.

My vote is for .lucee to use "class" instead of "component". I’d prefer to drop the "function" keyword in declarations / definitions but I don’t feel strongly about it. And can we change "getComponentMetadata()" to "getClassMetadata()" with this too?

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



Michael Offner

unread,
Apr 23, 2015, 12:46:41 PM4/23/15
to lucee
"And can we change "getComponentMetadata()" to "getClassMetadata()" with this too?"
Sure, if we rename to "class", we have to do that renaming everywhere for this dialect:
- function names
- function arguments
- tag attributes
- doc (reference)
- exception messages
...

Tha will be the hard part, specially because for the cfml dialect we cannot change it.
Micha



--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Chip Pinkston

unread,
Apr 23, 2015, 12:48:35 PM4/23/15
to lu...@googlegroups.com
+1 for 'class' instead of 'component'
+1 for 'method' instead of 'function'

I'd like to see making ('method' | 'function') optional rather than just dropping entirely.


Chip.

Sean Corfield

unread,
Apr 23, 2015, 12:55:42 PM4/23/15
to lu...@googlegroups.com
On Apr 23, 2015, at 9:48 AM, Chip Pinkston <chippi...@gmail.com> wrote:
> +1 for 'class' instead of 'component'
> +1 for 'method' instead of 'function'

Whilst I’m in favor of renaming component to class, I have NOT in favor of renaming function to method. Here’s why:

function foo( a ) { return a + 1; }

var o = new SomeObject();

o.bar = foo;
o.baz = function ( x ) { return x * 2; };

var b = o.bar( 42 );
var c = o.baz( 13 );

Objects in CFML/Lucee have functions. They’re just regular functions that happen to rely on variables/this scope (which is dynamic and happens at runtime). They’re not some special thing that is different to a "function".

> I'd like to see making ('method' | 'function') optional rather than just dropping entirely.

By all means make "function" optional if it doesn’t mess with the parser too much, but PLEASE don’t call it "method"! Ugh!

Jesse Shaffer

unread,
Apr 23, 2015, 12:55:53 PM4/23/15
to lu...@googlegroups.com

I like Jeroen's suggestion in that regard, and will expound upon it:

Options:
1. Disallow non-constant expressions in the immediate body of the class, so that you cannot call a tag there.

2. As soon as you specify an access modifier (public, private, static, abstract), the function keyword becomes optional.

You received this message because you are subscribed to a topic in the Google Groups "Lucee" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lucee/MzOw82hnzEg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Michael Offner

unread,
Apr 23, 2015, 12:58:32 PM4/23/15
to lucee
"1. Disallow non-constant expressions in the immediate body of the class, so that you cannot call a tag there."
no support for a constructor in the component body anymore or just limited?

Micha




Jesse Shaffer

unread,
Apr 23, 2015, 1:40:35 PM4/23/15
to lu...@googlegroups.com
Since the actual constructor is always going to be called, I'd probably err on the side of none at all in the immediate body of the class.  However, the case could be made for simple assignments (limited) being allowed:

class {
   
// could be valid - this is a "constant expression" where the value is known at compile time
   
this.value = 1;

   
// invalid - these are dynamic, and cannot be known at compile time

   
this.queryData = queryExecute("select * from somewhere");
   
this.data = url.param;

   
// invalid - tag execution
    mail subject
="instance created" to="some....@individu.al" {
        writeoutput
("why would you want emails everytime an instance is made???");
   
}

   
// invalid - these scopes should not be available here
    application
.instance = this;
    request
.instance = this;
    session
.instance = this;

   
// this is kinda tricky, it feels invalid to me - definitely unnecessary as you should be writing this as a member instead of assigning a closure, but it is a "constant expression" so idk...
   
this.closure = function() {}
   
   
public <however you define the constructor>() {
       
// all the above would be valid here...
   
}
}  

Adam Cameron

unread,
Apr 23, 2015, 2:02:38 PM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 17:09:53 UTC+1, Micha wrote:
what's about closures?
susi=function(){};

should we do this?
susi=(){};


Why not? as long as the parser can deal with it?
 
this would raise the question if we should only support Lambda functions then (with closure enviroment)...


Do you mean that in the sense that you'll only support functions as expressions (lambdas), not via statements (not lambdas)?

EG this:

f = (){}

But not this:

f(){}

Or do you mean this distinction you make between these two syntaxes currently:

f = function(){} // lambda
f = ()->{} // also a lambda, just with a different syntax

And if "function" was omitted, we've have this:

f = (){}

Which is unfeasibly similar to the "arrow function" syntax above?
?


If it's the former, I think there's place for both statement-based and expression-based functions.

If it's the latter: no, you should only have one of those syntaxes - and it should use closure - but I don't really care which. Although i think the arrow is redundant, if you can parse the code without it. Indeed, if you can parse the code without it, maybe you don't need it for the same thing in the CFML parser?

-- 
Adam

Adam Cameron

unread,
Apr 23, 2015, 2:20:32 PM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 17:13:13 UTC+1, Jesse Shaffer wrote:

Outside of a class, then yes, you would need the function keyword.

Why?

I mean why would it need it?

Wouldn't it be less than ideal to have two separate syntaxes for defining functions?

-- 
Adam

Adam Cameron

unread,
Apr 23, 2015, 2:21:50 PM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 17:38:13 UTC+1, Sean Corfield wrote:
On Apr 23, 2015, at 5:52 AM, Michael Offner <mic...@lucee.org> wrote:
I think because you can access them from remote, so you could say it is more than just a class it is a component...

Cheers for the history lesson & insight Sean!

-- 
Adam 

Adam Cameron

unread,
Apr 23, 2015, 2:24:15 PM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 17:58:32 UTC+1, Micha wrote:
"1. Disallow non-constant expressions in the immediate body of the class, so that you cannot call a tag there."
no support for a constructor in the component body anymore or just limited?


If there are proper constructor methods (or those static {} areas as per the new Lucee 5 feature), what would the purpose of code outwith the constructors / methods be?

(other than like import statements, etc)

-- 
Adam

Jesse Shaffer

unread,
Apr 23, 2015, 3:15:31 PM4/23/15
to lu...@googlegroups.com
For situations like this:

<cfscript>
/* index.cfm */

// plain jane function - not a closure.
function blah() {
   return 1;
}
</cfscript>

Also, because in general, CFScript is based moreso on ECMAScript.  However, since going into defining a class syntax is new territory, I'm fine with supporting the idea that class member methods do not need the function keyword.  In an effort to avoid scope-creep, I'd say at least for the time being, leave other function definitions alone.

Adam Cameron

unread,
Apr 23, 2015, 3:27:46 PM4/23/15
to lu...@googlegroups.com


On Thursday, 23 April 2015 20:15:31 UTC+1, Jesse Shaffer wrote:
For situations like this:

<cfscript>
/* index.cfm */

// plain jane function - not a closure.
function blah() {
   return 1;
}
</cfscript>

Also, because in general, CFScript is based moreso on ECMAScript.  However, since going into defining a class syntax is new territory, I'm fine with supporting the idea that class member methods do not need the function keyword.  In an effort to avoid scope-creep, I'd say at least for the time being, leave other function definitions alone.

Yep, fair enough. I'd not looked closely at the ECMA 6 spec, so was unaware the syntax for methods in classes is different from functions outside of classes.

But - yeah - it's reasonably an existing precedent that CFScript (erm... LuceeScript in this context?) follows ECMA's lead.

Good thinking, Jesse.

-- 
Ada

Konstantinos Liakos

unread,
Apr 23, 2015, 4:54:32 PM4/23/15
to lu...@googlegroups.com
+1 for class, removal of the function keyword inside class, deprecation of the pseudo-constructor.
Reply all
Reply to author
Forward
0 new messages