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

Viaduct Productions
Gotta love the compound data types.  I love maps, especially they can  
get big, they're easy to use, and they're fast.


On 27-Feb-09, at 8:05 AM, Jason Huck wrote:

> Both, really. The fewer variables you need to create, the better. As
> is often mentioned, if you find yourself needing to create a large
> number of variables on a page, it's more efficient to just put
> everything into a single map, or whatever data structure is most
> appropriate for your needs, whether one of the built-in ones or one of
> your own design (custom types).



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

CoMedia
In reply to this post by Viaduct Productions
Viaduct Productions wrote
This isn't about Fletcher.  It's common in other languages as well.  
The very reason we have those types is for different practices.  Why  
have variables if we don't need them?  For fun?
[Local] and [Variable] DO have their own practices. One should use [Local] when the value is only needed on that particular page (a throwaway variable, if you like), and [Variable] whenever the value must be passed to an include.

-- Alfred
Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

Viaduct Productions
In reply to this post by CoMedia
You have to learn how to quote text, Alfred.  Please separate it from  
what I said before.

All variables are tossed at the end of a page.  They are all throwaway  
unless you shove them into something else.  Given that includes can be  
used to create frameworks like the 1000-year-old Corral, and Fusebox,  
variables are used on a much higher frequency, and are considered to  
be any page storage unit.  Locals are known to be used inside custom  
tags.  Ever since I've been using Lasso, that's the way people have  
posted code in this list.


On 27-Feb-09, at 8:07 AM, CoMedia wrote:

>
>
> Viaduct Productions wrote:
>> This isn't about Fletcher.  It's common in other languages as well.
>> The very reason we have those types is for different practices.  Why
>> have variables if we don't need them?  For fun?[Local] and  
>> [Variable] DO
>> have their own practices. One should use [Local] when the value is  
>> only
>> needed on that particular page (a throwaway variable, if you like),  
>> and
>> [Variable] whenever the value must be passed to an include.
>
> -- Alfred



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
Kind of an interesting thread...actually.

In my mind it was linked to the one about usability.

Lasso allows you to do a lot of things that do not fall into the scope  
of "programming good practice." On the other hand they still make  
sense if you do not come from such a rigorous background, or you want  
to adopt a more unique style.

Like Jason's comments about variables. We all agree, but then again if  
you have multiple loops many would argue that the looping variable  
should be easily identified with its structure. So it is a judgment  
call.

If you really want to savor some goodies, then read Robert Martins  
book "Clean Code."

But back to tags!

A tag should have the ability to return more than one value. However,  
in most languages this winds up being a construct such an an array or  
map. But the ideal return is an object (i.e. custom type)  no  maps or  
arrays involved. Now I have done all of these before I get yelled at.

I love returning an object, but generally more painful to  debug  
without a line level debugger (This is actually a separate topic. I  
would love to know what others do)

But as soon as we talk objects we know that maybe only 50% of the  
lasso community use them.

So this response was more of a question  or rambling about "how to  
bridge the gap."

Deco







--
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 jasonhuck
Jason Huck wrote on 2/27/2009 6:43 AM:
> I use locals for all "throwaway" variables by convention.

Same here, any variable that isn't suppose to live beyond the container it's in.  FWIW, Kyle has mentioned a few times that he uses locals for just about everything.


- 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

stevepiercy
In reply to this post by Viaduct Productions
On Friday, February 27, 2009, [hidden email] (Viaduct Productions) pronounced:

>You have to learn how to quote text, Alfred.  Please separate it from  
>what I said before.

Yes, please.  I just used Nabble to follow up on an imagemagick montage thread, so it ain't Nabble messing it up.

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.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 decorior

On 27-Feb-09, at 8:40 AM, Deco Rior wrote:

> Kind of an interesting thread...actually.
>
> In my mind it was linked to the one about usability.
>
> Lasso allows you to do a lot of things that do not fall into the  
> scope of "programming good practice." On the other hand they still  
> make sense if you do not come from such a rigorous background, or  
> you want to adopt a more unique style.

True.  But if you go from procedural into OOP and you're using locals  
in your structure, then it could represent a major rewrite of your  
foundation.

I can only hope that while there are many ways to get things done,  
that any software company isn't inventing new items solely for the  
sake of fattening out the options without adding any features.  I  
mean, why support something that isn't needed?  In that sense you are  
introducing more work for no return.

> Like Jason's comments about variables. We all agree, but then again  
> if you have multiple loops many would argue that the looping  
> variable should be easily identified with its structure. So it is a  
> judgment call.
>
> If you really want to savor some goodies, then read Robert Martins  
> book "Clean Code."
>
> But back to tags!
>
> A tag should have the ability to return more than one value.  
> However, in most languages this winds up being a construct such an  
> an array or map. But the ideal return is an object (i.e. custom  
> type)  no  maps or arrays involved. Now I have done all of these  
> before I get yelled at.

OK, but strings, integers, decimals...as simple as you can get, are  
all objects.  When we say string->lowercase, that is actually saying  
"take this type, apply the lowercase method to it".

> I love returning an object, but generally more painful to  debug  
> without a line level debugger (This is actually a separate topic. I  
> would love to know what others do)

So you do it more often than you think.  And compound data types,  
namely array or map, can make sure you have available more than 1  
value coming out of a ctag.  On top of that, more ctags can be  
implemented to grab the value you want out of that result.

> But as soon as we talk objects we know that maybe only 50% of the  
> lasso community use them.

100%, they're just misunderstood.

> So this response was more of a question  or rambling about "how to  
> bridge the gap."



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
I guess in a onefile situation, that isn't possible.


On 27-Feb-09, at 9:54 AM, Bil Corry wrote:

> Same here, any variable that isn't suppose to live beyond the  
> container it's in.  FWIW, Kyle has mentioned a few times that he  
> uses locals for just about everything.



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 Viaduct Productions

On Feb 27, 2009, at 8:21 AM, Viaduct Productions wrote:

>> But as soon as we talk objects we know that maybe only 50% of the  
>> lasso community use them.
>
> 100%, they're just misunderstood.

Yes, and in Lasso 9 more things become objects :-)

I should have been more explicit and said custom types, and the type  
of example below.

And there is confusion.

For example, it was suggested that sometimes a tag should return a map.

So now the nomenclature becomes:

#myreturn->find('a');

But returning a custom type (ie. lasso object) would provide this

#myreturn->a

The latter is almost "more" consistent, but the first is certainly  
easier for many and found in a lot of code (and maybe faster).


In fact I don't think I have seen a tag on tag swap to convert a map  
to a custom type.

We rolled our own tags so we to deal with everything consistently now.

Deco







--
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 fact I don't think I have seen a tag on tag swap to convert a map to a
> custom type.

If you just want automatic getters/setters, you could return (or
subclass) a [dictionary] instead:

http://tagswap.net/dictionary

- jason


--
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
In reply to this post by decorior

On 27-Feb-09, at 11:49 AM, Deco Rior wrote:

> But returning a custom type (ie. lasso object) would provide this
>
> #myreturn->a

$myReturn->'a', but there's discussion about getters.  Essentially it  
should be this, from what I understand:

$myReturn->get('a');

> The latter is almost "more" consistent, but the first is certainly  
> easier for many and found in a lot of code (and maybe faster).

A map is just a type, and the member tag, ->find(blah) is the getter.

>
> In fact I don't think I have seen a tag on tag swap to convert a map  
> to a custom type.
>
> We rolled our own tags so we to deal with everything consistently now.



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

Fletcher Sandbeck-3
In reply to this post by decorior
On 2/27/09 at 9:49 AM, [hidden email] (Deco Rior) wrote:

>For example, it was suggested that sometimes a tag should return a map.
>
>So now the nomenclature becomes:
>
>#myreturn->find('a');
>
>But returning a custom type (ie. lasso object) would provide this
>
>#myreturn->a
>
>The latter is almost "more" consistent, but the first is
>certainly easier for many and found in a lot of code (and maybe faster).

I prefer using ->find since it uses a separate name space from
that of instance variables for the type.  For example, you can
do ->find('type'), but you can't really overload ->type.

[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

Bil Corry-3
In reply to this post by decorior
Deco Rior wrote on 2/27/2009 10:49 AM:
> So now the nomenclature becomes:
>
> #myreturn->find('a');
>
> But returning a custom type (ie. lasso object) would provide this
>
> #myreturn->a

That's how my lp_inline_dataset works, each row returned is a ctype that allows you to specify the column name like this:

        $row->first_name + ' ' + $row->last_name;

        (see: http://tagswap.net/lp_inline_dataset)

But getting back to your point, it was discussed in 2004 with Greg offering up [fwp_map] and I offered a patch to the built-in map:

        http://listsearch.com/Lasso/Thread/index.lasso?10681

But as Fletcher has pointed out, it won't work when there's already an existing member tag of the same name...


- 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

decorior
In reply to this post by jasonhuck
Thanks, Jason

I had forgotten about that one!

On Feb 27, 2009, at 9:52 AM, Jason Huck wrote:

>> In fact I don't think I have seen a tag on tag swap to convert a  
>> map to a
>> custom type.
>
> If you just want automatic getters/setters, you could return (or
> subclass) a [dictionary] instead:
>
> http://tagswap.net/dictionary
>
> - jason
>
>
> --
> 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/
>
>



--
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 Viaduct Productions

On Feb 27, 2009, at 9:52 AM, Viaduct Productions wrote:

> $myReturn->'a', but there's discussion about getters.  Essentially  
> it should be this, from what I understand:
>
> $myReturn->get('a');

Most languages seem to have adopted the minimal option.



--
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
Sure.  But again, in light of proper respect for methods, getters and  
setters should be manipulating direct changes/reads from properties.  
The direct call of $item->a is more of a method call than a reference  
to the property.  The difference is demonstrated by:

$item->a;
$item->'a';


On 27-Feb-09, at 12:34 PM, Deco Rior wrote:

> Most languages seem to have adopted the minimal option.



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
But I think that gets us back to the point.

Lasso is blessed with the ability to let us write with the rigor of  
Smalltalk or the simplicity of Basic :-)

And is very lenient on us :-)


--
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

Göran Törnquist-2
In reply to this post by Viaduct Productions
Viaduct Productions wrote:
> I guess in a onefile situation, that isn't possible.
>
>
> On 27-Feb-09, at 9:54 AM, Bil Corry wrote:
>
>> Same here, any variable that isn't suppose to live beyond the
>> container it's in.  FWIW, Kyle has mentioned a few times that he uses
>> locals for just about everything.
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.

/Göran

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



--
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
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/


Reply | Threaded
Open this post in threaded view
|

Re: Search and replace using a map

decorior
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/


123