Feature req idea - thoughts please

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

Feature req idea - thoughts please

James Harvard
Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.

It would make it very easy to do something like this ...

$mystring->lowercase;
$mystring->get(1)->uppercase;

... instead of ...
$mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;

I can't see that such a change would be likely to break any existing code, but I might be wrong.

Thoughts?

James

--
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: Feature req idea - thoughts please

Adam de Zoete-2
James Harvard wrote:
> Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
> Thoughts?

How about:

String->TitleCase

http://reference.lassosoft.com/Reference.LassoApp?[String-%3ETitleCase]

Is that the same as what you're after?

Adam


--
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: Feature req idea - thoughts please

James Harvard
In reply to this post by James Harvard
At 16:21 +0100 13/5/09, Adam de Zoete wrote:
>String->TitleCase

Thanks, but no, that's not what I'm after. It was a requirement for something similar that made me think about this, but that was just an example to illustrate my wider point. I was interested in whether people it would be a generally useful feature for the language.

James

>>Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
>>
>>It would make it very easy to do something like this ...
>>
>>$mystring->lowercase;
>>$mystring->get(1)->uppercase;
>>
>>... instead of ...
>>$mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;
>>
>>I can't see that such a change would be likely to break any existing code, but I might be wrong.
>>
>>Thoughts?
>>
>>James

--
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: Feature req idea - thoughts please

Bil Corry-3
James Harvard wrote on 5/13/2009 10:57 AM:
> I was interested in whether people it would be a generally useful
> feature for the language.

Sounds good to me.


- 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: Feature req idea - thoughts please

stevepiercy
In reply to this post by James Harvard
On Wednesday, May 13, 2009, [hidden email] (James Harvard) pronounced:

>Thoughts?

Useful!

--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: Feature req idea - thoughts please

Trevor Borgmeier
In reply to this post by James Harvard
I agree. This would be useful.

-Trevor


on 5/13/09 10:18 AM James Harvard wrote:

> Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
>
> It would make it very easy to do something like this ...
>
> $mystring->lowercase;
> $mystring->get(1)->uppercase;
>
> ... instead of ...
> $mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;
>
> I can't see that such a change would be likely to break any existing code, but I might be wrong.
>
> Thoughts?
>
> James
>
> --
> 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: Feature req idea - thoughts please

Steve Upton
In reply to this post by James Harvard
At 4:18 PM +0100 5/13/09, James Harvard wrote:

>Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
>
>It would make it very easy to do something like this ...
>
>$mystring->lowercase;
>$mystring->get(1)->uppercase;
>
>... instead of ...
>$mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;
>
>I can't see that such a change would be likely to break any existing code, but I might be wrong.
>
>Thoughts?

the only problem I see is in Lasso's implementation of chaining... which isn't really an "implementation of chaining" as much as the "way Lasso works"

In RealBasic, I can "extend" strings, numbers, etc with my own functions. So I can perform much the same kind of chaining. It is INDEED very useful.

But in RB when the string is "empty", things still function OK. I just need to ensure I can handle an empty string as input and all runs smoothly.

In Lasso, when a string is "empty" it doesn't exist. So all of a sudden I get an error like "null->coolStringFunction doesn't exist". I find it a pain and it seems like I need to check with each step of the chain for robust handling or just turn it all over to a protected block so it all gets thrown out if an error in the chain is found.

Is there a better way for Lasso to do this? Is there a better way for me to do it in Lasso?

I'd love to see more chaining possibilities in Lasso, if chaining didn't have a "weak link"

regards,

Steve



--


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

What should I be looking for when I get this error??

Michael Benedict
Here is the error....
Lasso Connector could not communicate with Lasso Service.
Server returned malformed header.

If I restart Lasso it goes away, but what is making it happen..

Many thanks in advance.. Michael




--
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: Feature req idea - thoughts please

James Harvard
In reply to this post by Steve Upton
What you are encountering is the same sort of distinction between a null value and a zero-length string that is seen in SQL.

Null is a separate type (class) in Lasso and thus does not support the string type's member tags (functions) in the same way that, for example, the string type does not support date type functions like date->month. If an action_param is not submitted by the browser it will return null, not zero-length string (''). You can test this using action_param('not_submitted')->type.

Although it is logical I agree it is a pain to code around it all the time! The simplest & most robust thing to do is always explicitly cast to a string before using string member tags.

string(action_param('may_exist_or_may_not'))->lowercase&->split('/')&->removelast&->join('/');

HTH,
James

>the only problem I see is in Lasso's implementation of chaining... which isn't really an "implementation of chaining" as much as the "way Lasso works"
>
>In RealBasic, I can "extend" strings, numbers, etc with my own functions. So I can perform much the same kind of chaining. It is INDEED very useful.
>
>But in RB when the string is "empty", things still function OK. I just need to ensure I can handle an empty string as input and all runs smoothly.
>
>In Lasso, when a string is "empty" it doesn't exist. So all of a sudden I get an error like "null->coolStringFunction doesn't exist". I find it a pain and it seems like I need to check with each step of the chain for robust handling or just turn it all over to a protected block so it all gets thrown out if an error in the chain is found.
>
>Is there a better way for Lasso to do this? Is there a better way for me to do it in Lasso?
>
>I'd love to see more chaining possibilities in Lasso, if chaining didn't have a "weak link"
>
>regards,
>
>Steve

--
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: Feature req idea - thoughts please

Bil Corry-3
James Harvard wrote on 5/13/2009 9:08 PM:
> You can test this
> using action_param('not_submitted')->type.

It returns 'string':

        [action_param('bah')->type]

As far as I know, it has always returned string.  Maybe you're thinking of data coming from MySQL?  I think if a column is NULL, Lasso assigns it as type [null].


- 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: Feature req idea - thoughts please

jasonhuck
In reply to this post by James Harvard
> string(action_param('may_exist_or_may_not'))->lowercase&->split('/')&->removelast&->join('/');

Minor note: &-> is redundant. All you need is the &:

string(action_param('may_exist_or_may_not'))->lowercase&split('/')&removelast&join('/');

I thoroughly abuse Lasso's chaining via the retarget operator and do
multiple operations in a single statement like the one above all the
time. I have no particular qualms with how it works.

- 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: Feature req idea - thoughts please

Johan Solve
In reply to this post by James Harvard
The missing link here is that there is no character class in Lasso -
the smallest component of a string is the string itself. Characters
are not "elements" of a string in the way an array consists of
elements.
So when you retreive an individual character using ->get it is
immediately copied out of the string into a new string with just one
character. In other words there is no way to address an individual
character within a string to be able to manipulate it.

What you can do is simulate a string as a bunch of character elements
by splitting the string into an array, manipulate an individual
element and then join it back to a string again.

var('stringelements'='a quick fox' -> split(''));
$stringelements -> get(3) -> uppercase;
$stringelements -> join;


On Wed, May 13, 2009 at 5:18 PM, James Harvard
<[hidden email]> wrote:

> Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
>
> It would make it very easy to do something like this ...
>
> $mystring->lowercase;
> $mystring->get(1)->uppercase;
>
> ... instead of ...
> $mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;
>
> I can't see that such a change would be likely to break any existing code, but I might be wrong.
>
> Thoughts?
>
> James
>
> --
> 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/
>
>
>



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm   Malmö
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

--
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: Feature req idea - thoughts please

Johan Solve
Here's a little experiment to implement better support for addressing
character elements wihtin a string. See it as a simple proof of
concept - there are many things that won't work as they should so
basically the only think you can do with the mystring type is to
output the manuipulated string (that's what the onconvert tag is for),
all other string member tags will work on the original string value
instead of the stringelements value.

define_type('mystring', 'string');
        local('stringelements'=null);
        define_tag('get', -required='index');
                self->'stringelements'=self -> split('');
                return(@(self->'stringelements' -> get(#index)));
        /define_tag;
        define_tag('onconvert');
                self -> 'stringelements' -> isa('array') ? return(self ->
'stringelements' -> join);
                return(self->parent);
        /define_tag;
/define_type;

var('test'=mystring('quick brown fox'));
$test -> get('15') -> uppercase;
$test;


On Thu, May 14, 2009 at 9:01 AM, Johan Solve <[hidden email]> wrote:

> The missing link here is that there is no character class in Lasso -
> the smallest component of a string is the string itself. Characters
> are not "elements" of a string in the way an array consists of
> elements.
> So when you retreive an individual character using ->get it is
> immediately copied out of the string into a new string with just one
> character. In other words there is no way to address an individual
> character within a string to be able to manipulate it.
>
> What you can do is simulate a string as a bunch of character elements
> by splitting the string into an array, manipulate an individual
> element and then join it back to a string again.
>
> var('stringelements'='a quick fox' -> split(''));
> $stringelements -> get(3) -> uppercase;
> $stringelements -> join;
>
>
> On Wed, May 13, 2009 at 5:18 PM, James Harvard
> <[hidden email]> wrote:
>> Don't know if it's possible or practical for Lassosoft to implement, but I think it would be useful if string->get returned a reference to the original character so that, like arrays etc, strings could be iterated and each character modified in place.
>>
>> It would make it very easy to do something like this ...
>>
>> $mystring->lowercase;
>> $mystring->get(1)->uppercase;
>>
>> ... instead of ...
>> $mystring = ($mystring->get(1)->uppercase& + $mystring->lowercase&->remove(1,1)&) ;
>>
>> I can't see that such a change would be likely to break any existing code, but I might be wrong.
>>
>> Thoughts?
>>
>> James
>>
>> --
>> 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/
>>
>>
>>
>
>
>
> --
> Mvh
> Johan Sölve
> ____________________________________
> Montania System AB
> Halmstad   Stockholm   Malmö
> http://www.montania.se
>
> Johan Sölve
> Mobil +46 709-51 55 70
> [hidden email]
>
> Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
> Telefon +46 35-136800 |  Fax +46 35-136801
>
> --
> 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/
>
>
>



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm   Malmö
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

--
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: Feature req idea - thoughts please

James Harvard
In reply to this post by Bil Corry-3
Eh?

You're right, of course, but it's odd that I had got that idea so firmly lodged in my head! I did know about the null column thing too, so it wasn't confusion over that.

It's probably from working with some app code that converts action_params to vars, so in that case var('this_param_not_submitted')===null.

James

>James Harvard wrote on 5/13/2009 9:08 PM:
>> You can test this
>> using action_param('not_submitted')->type.
>
>It returns 'string':
>
> [action_param('bah')->type]
>
>As far as I know, it has always returned string.  Maybe you're thinking of data coming from MySQL?  I think if a column is NULL, Lasso assigns it as type [null].
>
>- 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/