Search and replace using a map

classic Classic list List threaded Threaded
58 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

jasonhuck
# and $ only differ within the context of a custom tag/type, because
it's the only place where a different scope is enforced, with or
without an explicit namespace.

[inlines] have a "pseudo-scope" in terms of error management and
access to action_params, but not in terms of variables. [protect]
blocks have a pseudo scope in terms of error management but nothing
else.

so, anywhere within the _page_ namespace, # and $ are interchangeable.
you can even do this:

local('foo') = 'bar';
$foo;

-> bar

and vice versa.

- jason






On Fri, Feb 27, 2009 at 12:58 PM, Viaduct Productions
<[hidden email]> wrote:

> So there's no difference between how locals and variables?  What's the
> difference between $ and #?  If that is the case, it's a waste of time, and
> completely misleading.
>
>
> On 27-Feb-09, at 12:50 PM, Göran Törnquist wrote:
>
>> I'm doing onefile solutions. Still using locals as described earlier in
>> this thread. Since the scoop is the same as for page variables, the
>> difference - between using them and not using them - is purely coding style
>> supposed to help readability.
>
>
>
> Rich in Toronto
> ...now go get on your bike
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

jasonhuck
In reply to this post by decorior
I have seen this occasionally but never detemined exactly what
conditions cause it to occur. I believe it may have something to do
with running your entire page from within an include in the context of
using [define_atbegin] to handle virtual URL's, but that may just be
coincidence.

I've taken it as an opportunity to correct mistakes in my code. Even
if they work the same way, I still want to be consistent and refer to
locals with # and vars with $.

JLH




On Fri, Feb 27, 2009 at 1:10 PM, Deco Rior <[hidden email]> wrote:

> Am I wrong but I thought that if I defined a local on a page and then
> referenced it with $ instead of # I got an error....but not vice versa.
>
> Deco
> On Feb 27, 2009, at 10:58 AM, Viaduct Productions wrote:
>
>> So there's no difference between how locals and variables?  What's the
>> difference between $ and #?  If that is the case, it's a waste of time, and
>> completely misleading.
>>
>>
>> On 27-Feb-09, at 12:50 PM, Göran Törnquist wrote:
>>
>>> I'm doing onefile solutions. Still using locals as described earlier in
>>> this thread. Since the scoop is the same as for page variables, the
>>> difference - between using them and not using them - is purely coding style
>>> supposed to help readability.
>>
>>
>>
>> Rich in Toronto
>> ...now go get on your bike
>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Bil Corry-3
In reply to this post by Viaduct Productions
Viaduct Productions wrote on 2/27/2009 11:58 AM:
> So there's no difference between how locals and variables?  What's the
> difference between $ and #?  If that is the case, it's a waste of time,
> and completely misleading.

There is a difference in some circumstances, notably ctags, ctypes and enclosures:

        {
                local('a') = 1;
                var('b') = 2;
        }->run;
        local_defined('a');'<br>';
        var_defined('b');

Returns:

        false
        true

And even if it's a subtle hint to the developer, I still use it as such.


- Bil




--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
Well there goes that.

How can that local not be defined?  The thread just said that there is  
no difference between the two, and now it is showing it isn't even  
being respected.


On 27-Feb-09, at 1:15 PM, Bil Corry wrote:

> There is a difference in some circumstances, notably ctags, ctypes  
> and enclosures:
>
> {
> local('a') = 1;
> var('b') = 2;
> }->run;
> local_defined('a');'<br>';
> var_defined('b');
>
> Returns:
>
> false
> true
>
> And even if it's a subtle hint to the developer, I still use it as  
> such.



Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

jasonhuck
It's in a compound expression, which is essentially an anonymous
function (ctag) so it has the same scope as a ctag. Ctags and types
are the only place the separate scope is actually enforced.

- jason



On Fri, Feb 27, 2009 at 1:20 PM, Viaduct Productions
<[hidden email]> wrote:

> Well there goes that.
>
> How can that local not be defined?  The thread just said that there is no
> difference between the two, and now it is showing it isn't even being
> respected.
>
>
> On 27-Feb-09, at 1:15 PM, Bil Corry wrote:
>
>> There is a difference in some circumstances, notably ctags, ctypes and
>> enclosures:
>>
>>        {
>>                local('a') = 1;
>>                var('b') = 2;
>>        }->run;
>>        local_defined('a');'<br>';
>>        var_defined('b');
>>
>> Returns:
>>
>>        false
>>        true
>>
>> And even if it's a subtle hint to the developer, I still use it as such.
>
>
>
> Rich in Toronto
> ...now go get on your bike
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
Chapter 15 is entirely wrong then.


On 27-Feb-09, at 1:23 PM, Jason Huck wrote:

> It's in a compound expression, which is essentially an anonymous
> function (ctag) so it has the same scope as a ctag. Ctags and types
> are the only place the separate scope is actually enforced.



Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

decorior
In reply to this post by jasonhuck

Thanks, Jason:






--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

jasonhuck
In reply to this post by Viaduct Productions
How so? If anything, maybe there's just a minor omission. It doesn't
explicitly state that it is possible to use local variables within the
page scope, but it also doesn't say that you can't. Otherwise the
descriptions seem to be very accurate.

- jason



On Fri, Feb 27, 2009 at 1:24 PM, Viaduct Productions
<[hidden email]> wrote:

> Chapter 15 is entirely wrong then.
>
>
> On 27-Feb-09, at 1:23 PM, Jason Huck wrote:
>
>> It's in a compound expression, which is essentially an anonymous
>> function (ctag) so it has the same scope as a ctag. Ctags and types
>> are the only place the separate scope is actually enforced.
>
>
>
> Rich in Toronto
> ...now go get on your bike
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
Page 223:  "Page variables are the most common type of variable in  
Lasso They only exist while the current Lasso page is executing. "

Apparently the same with Locals.

Same page, Table 2: $ = "Returns the value of a variable".  Apparently  
# does the same thing, and vice versa.

Page 224:  "<?LassoScript
  Variable: 'VariableName'='Variable Value';
  Variable: 'VariableName';
?>
-> Variable Value "

Missing local('VariableName');

Just below that:

"Variable values can also be retrieved using the $ symbol. The  
following LassoScript creates a variable named
VariableName, then retrieves the value of the variable using the $  
symbol. The result is Variable Value. "

Missing the whole ability to use local.

Page 229, Local Variables are instantly associated to custom tags and  
compound expressions.

Every reference in this chapter to locals is in a special case where  
locality is a real feature.  Nowhere does it mention that locals are,  
and can be used anywhere.

So now that this is opened up, I take it we can now add locals to  
sessions?


On 27-Feb-09, at 1:31 PM, Jason Huck wrote:

> How so? If anything, maybe there's just a minor omission. It doesn't
> explicitly state that it is possible to use local variables within the
> page scope, but it also doesn't say that you can't. Otherwise the
> descriptions seem to be very accurate.



Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
In reply to this post by Bil Corry-3
See, my point is that while the code Bil posted was respecting  
compound locality, I think locals are expected where locality is the  
issue, or expected use.

var('thing' = 'alpha');
local_defined('thing');

-> true;

That makes little sense to me.


On 27-Feb-09, at 1:15 PM, Bil Corry wrote:

> {
> local('a') = 1;
> var('b') = 2;
> }->run;
> local_defined('a');'<br>';
> var_defined('b');
>
> Returns:
>
> false
> true
>
> And even if it's a subtle hint to the developer, I still use it as  
> such.



Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

jasonhuck
In reply to this post by Viaduct Productions
I think the difference is semantics.

locals are only different from variables when a separate scope is
enforced. calling them locals when there is no separate scope doesn't
make them locals. at that point they are just variables.

at the time the documentation was written it was probably never
intended for people to use local() to defined variables outside of
custom tags and types, so they didn't mention how they would behave if
you did so.

- jason




On Fri, Feb 27, 2009 at 1:40 PM, Viaduct Productions
<[hidden email]> wrote:

> Page 223:  "Page variables are the most common type of variable in Lasso
> They only exist while the current Lasso page is executing. "
>
> Apparently the same with Locals.
>
> Same page, Table 2: $ = "Returns the value of a variable".  Apparently #
> does the same thing, and vice versa.
>
> Page 224:  "<?LassoScript
>  Variable: 'VariableName'='Variable Value';
>  Variable: 'VariableName';
> ?>
> ->      Variable Value "
>
> Missing local('VariableName');
>
> Just below that:
>
> "Variable values can also be retrieved using the $ symbol. The following
> LassoScript creates a variable named
> VariableName, then retrieves the value of the variable using the $ symbol.
> The result is Variable Value. "
>
> Missing the whole ability to use local.
>
> Page 229, Local Variables are instantly associated to custom tags and
> compound expressions.
>
> Every reference in this chapter to locals is in a special case where
> locality is a real feature.  Nowhere does it mention that locals are, and
> can be used anywhere.
>
> So now that this is opened up, I take it we can now add locals to sessions?
>
>
> On 27-Feb-09, at 1:31 PM, Jason Huck wrote:
>
>> How so? If anything, maybe there's just a minor omission. It doesn't
>> explicitly state that it is possible to use local variables within the
>> page scope, but it also doesn't say that you can't. Otherwise the
>> descriptions seem to be very accurate.
>
>
>
> Rich in Toronto
> ...now go get on your bike
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Fletcher Sandbeck-3
In reply to this post by Viaduct Productions
On 2/27/09 at 1:40 PM, [hidden email] (Viaduct
Productions) wrote:

>Page 223:  "Page variables are the most common type of variable
>in Lasso They only exist while the current Lasso page is
>executing. "
>
>Apparently the same with Locals.
>
>Same page, Table 2: $ = "Returns the value of a variable".  
>Apparently # does the same thing, and vice versa.
>
>Page 224:  "<?LassoScript
>Variable: 'VariableName'='Variable Value';
>Variable: 'VariableName';
>?>
>->    Variable Value "
>
>Missing local('VariableName');
>
>Just below that:
>
>"Variable values can also be retrieved using the $ symbol. The
>following LassoScript creates a variable named VariableName, then
>retrieves the value of the variable using the $ symbol. The result is
>Variable Value. "
>
>Missing the whole ability to use local.
>
>Page 229, Local Variables are instantly associated to custom
>tags and compound expressions.
>
>Every reference in this chapter to locals is in a special case where
>locality is a real feature.  Nowhere does it mention that locals are,
>and can be used anywhere.
>
>So now that this is opened up, I take it we can now add locals to sessions?

I wouldn't recommend using locals in this fashion.  In Lasso 8.5
the namespace of locals happens to coincide with the namespace
of variables in one context.  However, taking advantage of this
can be confusing since in very similar contexts the same code
will fail.

Variables should be used for storing values that will be
accessed through your page.  Locals should be used in specific
contexts like custom tags and compound expressions.

[fletcher]

--
Fletcher Sandbeck                         [hidden email]
LassoSoft, LLC                          http://www.lassosoft.com



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Trevor Borgmeier
In reply to this post by jasonhuck
I think local vars are local to the context in which they are declared.  
If a local var is declared within the scope of a page (and not a
sub-scope) it remains local to the page making it synonymous with a page
variable.

That being said I tend to only use them within custom tags.  If there is
an official preferred way/space to use locals I'd like to know too...

-Trevor



on 2/27/09 12:48 PM Jason Huck wrote:

> I think the difference is semantics.
>
> locals are only different from variables when a separate scope is
> enforced. calling them locals when there is no separate scope doesn't
> make them locals. at that point they are just variables.
>
> at the time the documentation was written it was probably never
> intended for people to use local() to defined variables outside of
> custom tags and types, so they didn't mention how they would behave if
> you did so.
>
> - jason
>
>
>
>
> On Fri, Feb 27, 2009 at 1:40 PM, Viaduct Productions
> <[hidden email]> wrote:
>  
>> Page 223: �"Page variables are the most common type of variable in Lasso
>> They only exist while the current Lasso page is executing. "
>>
>> Apparently the same with Locals.
>>
>> Same page, Table 2: $ = "Returns the value of a variable". �Apparently #
>> does the same thing, and vice versa.
>>
>> Page 224: �"<?LassoScript
>> �Variable: 'VariableName'='Variable Value';
>> �Variable: 'VariableName';
>> ?>
>> -> � � �Variable Value "
>>
>> Missing local('VariableName');
>>
>> Just below that:
>>
>> "Variable values can also be retrieved using the $ symbol. The following
>> LassoScript creates a variable named
>> VariableName, then retrieves the value of the variable using the $ symbol.
>> The result is Variable Value. "
>>
>> Missing the whole ability to use local.
>>
>> Page 229, Local Variables are instantly associated to custom tags and
>> compound expressions.
>>
>> Every reference in this chapter to locals is in a special case where
>> locality is a real feature. �Nowhere does it mention that locals are, and
>> can be used anywhere.
>>
>> So now that this is opened up, I take it we can now add locals to sessions?
>>
>>
>> On 27-Feb-09, at 1:31 PM, Jason Huck wrote:
>>
>>    
>>> How so? If anything, maybe there's just a minor omission. It doesn't
>>> explicitly state that it is possible to use local variables within the
>>> page scope, but it also doesn't say that you can't. Otherwise the
>>> descriptions seem to be very accurate.
>>>      
>>
>> Rich in Toronto
>> ...now go get on your bike
>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>>
>>    
>
>
>
>  


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Trevor Borgmeier
Fletcher is always at least two steps ahead of me.

on 2/27/09 12:59 PM Trevor Borgmeier wrote:

> I think local vars are local to the context in which they are
> declared.  If a local var is declared within the scope of a page (and
> not a sub-scope) it remains local to the page making it synonymous
> with a page variable.
>
> That being said I tend to only use them within custom tags.  If there
> is an official preferred way/space to use locals I'd like to know too...
>
> -Trevor
>
>
>
> on 2/27/09 12:48 PM Jason Huck wrote:
>> I think the difference is semantics.
>>
>> locals are only different from variables when a separate scope is
>> enforced. calling them locals when there is no separate scope doesn't
>> make them locals. at that point they are just variables.
>>
>> at the time the documentation was written it was probably never
>> intended for people to use local() to defined variables outside of
>> custom tags and types, so they didn't mention how they would behave if
>> you did so.
>>
>> - jason
>>
>>
>>
>>
>> On Fri, Feb 27, 2009 at 1:40 PM, Viaduct Productions
>> <[hidden email]> wrote:
>>  
>>> Page 223: �"Page variables are the most common type of variable in
>>> Lasso
>>> They only exist while the current Lasso page is executing. "
>>>
>>> Apparently the same with Locals.
>>>
>>> Same page, Table 2: $ = "Returns the value of a variable".
>>> �Apparently #
>>> does the same thing, and vice versa.
>>>
>>> Page 224: �"<?LassoScript
>>> �Variable: 'VariableName'='Variable Value';
>>> �Variable: 'VariableName';
>>> ?>
>>> -> � � �Variable Value "
>>>
>>> Missing local('VariableName');
>>>
>>> Just below that:
>>>
>>> "Variable values can also be retrieved using the $ symbol. The
>>> following
>>> LassoScript creates a variable named
>>> VariableName, then retrieves the value of the variable using the $
>>> symbol.
>>> The result is Variable Value. "
>>>
>>> Missing the whole ability to use local.
>>>
>>> Page 229, Local Variables are instantly associated to custom tags and
>>> compound expressions.
>>>
>>> Every reference in this chapter to locals is in a special case where
>>> locality is a real feature. �Nowhere does it mention that locals
>>> are, and
>>> can be used anywhere.
>>>
>>> So now that this is opened up, I take it we can now add locals to
>>> sessions?
>>>
>>>
>>> On 27-Feb-09, at 1:31 PM, Jason Huck wrote:
>>>
>>>    
>>>> How so? If anything, maybe there's just a minor omission. It doesn't
>>>> explicitly state that it is possible to use local variables within the
>>>> page scope, but it also doesn't say that you can't. Otherwise the
>>>> descriptions seem to be very accurate.
>>>>      
>>>
>>> Rich in Toronto
>>> ...now go get on your bike
>>>
>>>
>>>
>>> --
>>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>>
>>>
>>>
>>>    
>>
>>
>>
>>  
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Marc Pinnell-3
In reply to this post by Fletcher Sandbeck-3
Fletcher,

Your comments bring a concern to mind. I have been using locals almost  
exclusively on pages lately (don't remember why I changed, maybe it  
was just easier to see). Sounds like a few others might be using  
locals heavily in circumstances, based on what you said below, where  
they/we should have been using vars. Going forward into Lasso 9, are  
we in trouble with backwards compatibility? Hope not, really don't  
want to think about recoding all those pages!

marc


On Feb 27, 2009, at 10:55 AM, Fletcher Sandbeck wrote:

> I wouldn't recommend using locals in this fashion.  In Lasso 8.5 the  
> namespace of locals happens to coincide with the namespace of  
> variables in one context.  However, taking advantage of this can be  
> confusing since in very similar contexts the same code will fail.
>
> Variables should be used for storing values that will be accessed  
> through your page.  Locals should be used in specific contexts like  
> custom tags and compound expressions.
>
> [fletcher]

--
Marc Pinnell
1027 Design
PO Box 990872
Redding, CA 96099-0872
530.941.4706
fax: 866.232.5300
www.1027Design.com





--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
In reply to this post by jasonhuck

On 27-Feb-09, at 1:48 PM, Jason Huck wrote:

> I think the difference is semantics.
>
> locals are only different from variables when a separate scope is
> enforced. calling them locals when there is no separate scope doesn't
> make them locals. at that point they are just variables.
>
> at the time the documentation was written it was probably never
> intended for people to use local() to defined variables outside of
> custom tags and types, so they didn't mention how they would behave if
> you did so.


But your definition agrees with the same:

The country has 2 currencies.  Some observations:

- the use of locals is forced inside compound statements and ctags
- you can use locals anywhere else
- variables are obviously not going to be used in ctags and could be  
used in compound statements

This leads to "what are variables for then?"  If you chose to use  
locals only, then there's absolutely no need for variables whatsoever,  
because the structure is fully respected just by using locals.  It  
would reduce a lot of confusion if locals were only used.


Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
In reply to this post by Fletcher Sandbeck-3
Yes, that's exactly how I am using them, and would have hoped that  
there were items in place to force such an application.

Vars:  Normal, page level storage and reference.

Locals:  Smaller temporary tools that hide from Var-level application.

The issue is that it's been brought up that if you use locals only,  
you can get away with exactly what you want to achieve.  While that  
might be 'possible', I do remember it being right to use vars in that  
application.  I'm not too clear on the namespace ramifications  
though.  Maybe that's where our deciphering qualifier lies.


On 27-Feb-09, at 1:55 PM, Fletcher Sandbeck wrote:

> I wouldn't recommend using locals in this fashion.  In Lasso 8.5 the  
> namespace of locals happens to coincide with the namespace of  
> variables in one context.  However, taking advantage of this can be  
> confusing since in very similar contexts the same code will fail.
>
> Variables should be used for storing values that will be accessed  
> through your page.  Locals should be used in specific contexts like  
> custom tags and compound expressions.



Rich in Toronto
...now go get on your bike



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Trevor Borgmeier
In reply to this post by Viaduct Productions
on 2/27/09 4:22 PM Viaduct Productions wrote:

> But your definition agrees with the same:
>
> The country has 2 currencies.  Some observations:
>
> - the use of locals is forced inside compound statements and ctags
> - you can use locals anywhere else
> - variables are obviously not going to be used in ctags and could be
> used in compound statements
>
> This leads to "what are variables for then?"  If you chose to use
> locals only, then there's absolutely no need for variables whatsoever,
> because the structure is fully respected just by using locals.  It
> would reduce a lot of confusion if locals were only used.
>
There is still use for page scope variables as sometimes you need to
carry a value from a local scope (ctag) to the page scope.  A real world
example would be with fletchers capture/collect tag.  Tag a look at his
code...

<?LassoScript

    define_tag('collect',
                -optional='var',
                -optional='insert',
                -optional='output',
                -container
    );
        local('collect') = run_children;
        local('types') = array('array', 'list', 'queue', 'set', 'stack');
        var('__collect_result__') = #collect;
        local_defined('var') && #var->isa('string') ? var(#var) = #collect;
       
        if(local_defined('insert'));
            if(#types >> #insert->type);
                #insert->insert(#collect);
            else(#insert->isa('string') && var_defined(#insert) &&
(#types >> var(#insert)->type));
                var(#insert)->insert(#collect);
            /if;
        /if;
       
        if(local_defined('output') && #output !== false);
            return(#collect);
        /if;
    /define_tag;
   
    define_tag('collect_result');
        return(var('__collect_result__'));
    /define_tag;

?>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


123