Lucee 5 variable modifiers questions

73 views
Skip to first unread message

Steven Neiland

unread,
Apr 9, 2015, 4:41:42 PM4/9/15
to lu...@googlegroups.com
So I was reading Adam latest blog post about the lucee 5 property modifiers and I had a thought. Up until now I have used the this scope for public variables and the variables scope for private variables like this:

component {
   variables.var1 = "accessible only inside this component";
   this.var2 = "accessible from outside this component";
}

In my mind i equate this to:

//sudo code equiv
component {
   private var1 = "accessible only inside this component";
   public var2 = "accessible from outside this component";
}

With these new modifiers I would expect to rewrite my code like this:

// new way
component {
   private this.var1 = "accessible only inside this component";
   public this.var2 = "accessible from outside this component";
}

Question #1: Do the access modifiers also work for variables scoped variables? i.e.

private variables.var1 = "accessible only inside this component";

Question #2: Regardless of the answer to Q1, Is specifying the this scope not redundant now? In my head I now read the new way as being this
 
public this.var2 == public public var2

I guess what Im really wondering wondering is if eventually we can write our code like this. Where we can drop specifying the this scope altogether in the variable declaration in the component body and only need to specify it within a function that accesses it.

component {
   private var1 = "accessible only inside this component";
   public var2 = "accessible from outside this component";

   public function doSomething(){
     if( this.var1 == this.var2){
       //do something else
     }
   }
}

Michael Offner

unread,
Apr 9, 2015, 4:50:07 PM4/9/15
to lu...@googlegroups.com
See my comments between the lines.
Micha


Am Donnerstag, 9. April 2015 schrieb Steven Neiland :
So I was reading Adam latest blog post about the lucee 5 property modifiers and I had a thought. Up until now I have used the this scope for public variables and the variables scope for private variables like this:

component {
   variables.var1 = "accessible only inside this component";
   this.var2 = "accessible from outside this component";
}

In my mind i equate this to:

//sudo code equiv
component {
   private var1 = "accessible only inside this component";
   public var2 = "accessible from outside this component";
}

With these new modifiers I would expect to rewrite my code like this:

// new way
component {
   private this.var1 = "accessible only inside this component";
   public this.var2 = "accessible from outside this component";
}

Question #1: Do the access modifiers also work for variables scoped variables? i.e.
No they only work for the this scope, the variables scope is always private.
 


private variables.var1 = "accessible only inside this component";

Question #2: Regardless of the answer to Q1, Is specifying the this scope not redundant now? 
A big yes, you could always disable the variables scope in Lucee/Railo and set the this scope to private. In the new Lucee dialect components have no variables scope ...
 
In my head I now read the new way as being this
 
public this.var2 == public public var2

I guess what Im really wondering wondering is if eventually we can write our code like this. Where we can drop specifying the this scope altogether in the variable declaration in the component body and only need to specify it within a function that accesses it.

component {
   private var1 = "accessible only inside this component";
   public var2 = "accessible from outside this component";

   public function doSomething(){
     if( this.var1 == this.var2){
       //do something else
     }
   }
}
 

--
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/01343201-dfcc-4e9d-bbc6-904ae478cc0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Neiland

unread,
Apr 10, 2015, 11:45:39 AM4/10/15
to lu...@googlegroups.com

Excellent! Great work.
Reply all
Reply to author
Forward
0 new messages