Lasso9 take 16: ->substring(start, length)

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

Lasso9 take 16: ->substring(start, length)

Marc Vos
Hi,

The method ->substring(start, length) behaves different in L9 when the string is empty (not null but really empty)

In L8, you can do this:

        string('')->substring(1,52)

In L9 this throws an error: 'String was empty'.

So, is this a bug in L9 or in L8 ??

- -
Thanks,
Marc

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Kyle Jessup-2

On Mar 3, 2013, at 2:00 PM, Marc Vos <[hidden email]> wrote:

> Hi,
>
> The method ->substring(start, length) behaves different in L9 when the string is empty (not null but really empty)
>
> In L8, you can do this:
>
> string('')->substring(1,52)
>
> In L9 this throws an error: 'String was empty'.
>
> So, is this a bug in L9 or in L8 ??

Since substring is there only for LP8 compatibility (L9 prefers the more universal ->sub()) then I'd say clearly that L9's substring needs to be adjusted here.

http://source.lassosoft.com/svn/lasso/lasso9_source/trunk/compat/compat.string.lasso (bottom)

There are probably half a dozen other quirks it's not adhering to as well.

But, looking at the intended behavior of ->sub() I'd say that it needs to be adjusted as well. Since the 1 just indicates the beginning of the string and the method doesn't guarantee to return the indicated number of characters then returning an empty string is appropriate in this case. If the first parameter were any other number then the method should still fail.

-Kyle

CC: bugs

>
> - -
> Thanks,
> Marc
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Jolle Carlestam-3
4 mar 2013 kl. 16:02 skrev Kyle Jessup <[hidden email]>:

> Since substring is there only for LP8 compatibility (L9 prefers the more universal ->sub()) then I'd say clearly that L9's substring needs to be adjusted here.
>
> http://source.lassosoft.com/svn/lasso/lasso9_source/trunk/compat/compat.string.lasso (bottom)
>
> There are probably half a dozen other quirks it's not adhering to as well.
>
> But, looking at the intended behavior of ->sub() I'd say that it needs to be adjusted as well. Since the 1 just indicates the beginning of the string and the method doesn't guarantee to return the indicated number of characters then returning an empty string is appropriate in this case. If the first parameter were any other number then the method should still fail.

For the record. I reported this in feb 2011 on the beta list. It resulted in a heated discussion spanning 54 replies. But also a statement from Kyle that it was a bug and should be fixed.

Might be that it never was. In the same discussion was a proposed fix from Göran that I implemented and have not thought about it since.

Odd detail. Marc Vos actually took part of that discussion as well. Looks like you've forgotten about it.

The fix:
define string->substring(pos::integer, size::integer) => (#pos > 0 && .size > 0 && #pos <= .size ? .sub(#pos, (#size <= .size ? #size | .size)) | '')

For those interested. It is dead easy to change, expand or tweak Lasso 9s built in behavior to suit your own needs. The above fix I have placed, together with other fixes in a file I call bugfixes.lasso. It is loaded at startup and will override Lassos default configs.

If you don't want to change the default you can just as easily expand using your own method names. Same as example:
define string->jc_substring(pos::integer, size::integer) => (#pos > 0 && .size > 0 && #pos <= .size ? .sub(#pos, (#size <= .size ? #size | .size)) | '')

This will leave substring as it is and introduce the call string -> jc_substring acting the way you want it.

Aint Lasso 9 just great!

HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Carl Ketterling
> For those interested. It is dead easy to change, expand or tweak Lasso 9s
> built in behavior to suit your own needs. The above fix I have placed,
> together with other fixes in a file I call bugfixes.lasso. It is loaded at
> startup and will override Lassos default configs.

That's a great idea, Joel.  Can you tell me where to read up on how to
configure such a file and make it load on startup?

Carl


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Marc Vos
In reply to this post by Kyle Jessup-2
Great! Thanks for your response!

Repaired in 9.2.6? ;-)

- -
Marc

Sent from my iPhone

On 4 mrt. 2013, at 16:02, Kyle Jessup <[hidden email]> wrote:

>
> On Mar 3, 2013, at 2:00 PM, Marc Vos <[hidden email]> wrote:
>
>> Hi,
>>
>> The method ->substring(start, length) behaves different in L9 when the string is empty (not null but really empty)
>>
>> In L8, you can do this:
>>
>>    string('')->substring(1,52)
>>
>> In L9 this throws an error: 'String was empty'.
>>
>> So, is this a bug in L9 or in L8 ??
>
> Since substring is there only for LP8 compatibility (L9 prefers the more universal ->sub()) then I'd say clearly that L9's substring needs to be adjusted here.
>
> http://source.lassosoft.com/svn/lasso/lasso9_source/trunk/compat/compat.string.lasso (bottom)
>
> There are probably half a dozen other quirks it's not adhering to as well.
>
> But, looking at the intended behavior of ->sub() I'd say that it needs to be adjusted as well. Since the 1 just indicates the beginning of the string and the method doesn't guarantee to return the indicated number of characters then returning an empty string is appropriate in this case. If the first parameter were any other number then the method should still fail.
>
> -Kyle
>
> CC: bugs
>
>>
>> - -
>> Thanks,
>> Marc
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso
>> [hidden email]
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Marc Vos
In reply to this post by Jolle Carlestam-3
Who? Who, me? Jolle, I forget a lot of things... ;-)

I rather wait for a proper Lasso 9 release.

- -
Thanks,
Marc

Sent from my iPhone

On 4 mrt. 2013, at 16:54, Jolle Carlestam <[hidden email]> wrote:

> 4 mar 2013 kl. 16:02 skrev Kyle Jessup <[hidden email]>:
>
>> Since substring is there only for LP8 compatibility (L9 prefers the more universal ->sub()) then I'd say clearly that L9's substring needs to be adjusted here.
>>
>> http://source.lassosoft.com/svn/lasso/lasso9_source/trunk/compat/compat.string.lasso (bottom)
>>
>> There are probably half a dozen other quirks it's not adhering to as well.
>>
>> But, looking at the intended behavior of ->sub() I'd say that it needs to be adjusted as well. Since the 1 just indicates the beginning of the string and the method doesn't guarantee to return the indicated number of characters then returning an empty string is appropriate in this case. If the first parameter were any other number then the method should still fail.
>
> For the record. I reported this in feb 2011 on the beta list. It resulted in a heated discussion spanning 54 replies. But also a statement from Kyle that it was a bug and should be fixed.
>
> Might be that it never was. In the same discussion was a proposed fix from Göran that I implemented and have not thought about it since.
>
> Odd detail. Marc Vos actually took part of that discussion as well. Looks like you've forgotten about it.
>
> The fix:
> define string->substring(pos::integer, size::integer) => (#pos > 0 && .size > 0 && #pos <= .size ? .sub(#pos, (#size <= .size ? #size | .size)) | '')
>
> For those interested. It is dead easy to change, expand or tweak Lasso 9s built in behavior to suit your own needs. The above fix I have placed, together with other fixes in a file I call bugfixes.lasso. It is loaded at startup and will override Lassos default configs.
>
> If you don't want to change the default you can just as easily expand using your own method names. Same as example:
> define string->jc_substring(pos::integer, size::integer) => (#pos > 0 && .size > 0 && #pos <= .size ? .sub(#pos, (#size <= .size ? #size | .size)) | '')
>
> This will leave substring as it is and introduce the call string -> jc_substring acting the way you want it.
>
> Aint Lasso 9 just great!
>
> HDB
> Jolle
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Jolle Carlestam-3
In reply to this post by Carl Ketterling
4 mar 2013 kl. 18:21 skrev "Carl Ketterling" <[hidden email]>:

>> For those interested. It is dead easy to change, expand or tweak Lasso 9s
>> built in behavior to suit your own needs. The above fix I have placed,
>> together with other fixes in a file I call bugfixes.lasso. It is loaded at
>> startup and will override Lassos default configs.
>
> That's a great idea, Joel.  Can you tell me where to read up on how to
> configure such a file and make it load on startup?
>
> Carl

To start with, Cerl, you want my help, you spell my name right.

Second, the easy way is to put the definition in a file, name it whatever.lasso and put it in the instance LassoStartup folder.

Note, if you replace existing methods you can't put the code in LassoLibraries, it won't be called since the method has already been defined.

You can however put the definitions in a LassoApp and have an _init.lasso page that loads the files at startup. This is the way I do it. It does require a bit further explanation than I can provide here. I'll try to compile an example once I get back to my computer.


HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: Lasso9 take 16: ->substring(start, length)

Rick Draper-2
> To start with, Cerl, you want my help, you spell my name right.

My favourite typo is Jello ;-)


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Jonathan Guthrie-3
In reply to this post by Jolle Carlestam-3
On 2013-03-04, at 1:48 PM, Jolle Carlestam <[hidden email]> wrote:

> To start with, Cerl, you want my help, you spell my name right.

Step 2, pronounce it right :)
There's no "J" in Jolle's phonetic name...
Am I right Jolle?

Jono

----------------------------
Jonathan Guthrie
[hidden email]
@iamjono
LassoSoft Inc.

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

decorior
Where is the second  o in your first name?

On Mar 4, 2013, at 12:03 PM, Jonathan Guthrie <[hidden email]> wrote:

> On 2013-03-04, at 1:48 PM, Jolle Carlestam <[hidden email]> wrote:
>
>> To start with, Cerl, you want my help, you spell my name right.
>
> Step 2, pronounce it right :)
> There's no "J" in Jolle's phonetic name...
> Am I right Jolle?
>
> Jono
>
> ----------------------------
> Jonathan Guthrie
> [hidden email]
> @iamjono
> LassoSoft Inc.
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: Lasso9 take 16: ->substring(start, length)

Rick Draper-2
In reply to this post by Jonathan Guthrie-3
> There's no "J" in Jolle's phonetic name...

The "J" is not completely silent, just subtle and subdued like the man himself... My guess is that he is having dinner.

Very best regards,

Rick


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Jolle Carlestam-3
4 mar 2013 kl. 20:10 skrev Rick Draper <[hidden email]>:

>> There's no "J" in Jolle's phonetic name...
>
> The "J" is not completely silent, just subtle and subdued like the man himself... My guess is that he is having dinner.

Subtle, now there's a description of me that's spot on!

Anywho, I'm generally fine with the different interpretations of how my name is pronounced. As long as you can hear the e at the end. And you spell it right. Hell, not even my own mother get the pronunciation right.

So, getting back to the topic at hand. Carl, here's a file that would work for you:

<?Lasso
stdoutnl('startup bugfixes.lasso load ' + date)

// temporary bug fixes. Always check if these are needed after a Lasso 9 update


// fix for a bug that produces an error if substring receives an empty string
define string -> substring(pos::integer, size::integer) => (#pos > 0 && .size > 0 && #pos <= .size ? .sub(#pos, (#size <= .size ? #size | .size)) | '')

// continue adding your own fixes here


stdoutnl('startup bugfixes.lasso loaded ' + date)

?>

I will try to compile an example of how I do the LassoApp thing. Is a really neat thing I learned from Jono.

HDB
Jello
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Jolle Carlestam-3
4 mar 2013 kl. 20:28 skrev Jolle Carlestam <[hidden email]>:

> So, getting back to the topic at hand. Carl, here's a file that would work for you:

Some more info that can be useful. Like where to put the file(s).
Provided you have a standard installation of Lasso 9 you will find the proper place for your files here:
/var/lasso/instances/default/LassoStartup/

If you have several instances running, change "default" to whatever your custom instance is called.

In LassoStartup I had a folder of my own that I called custom. I placed all my of types and methods in there. This to keep my stuff away from any that lasso installs by itself.

Using this solution the definitions are loaded at startup and can't be changed after that. While developing this is not a good place to keep your definitions. Place them here once you know they're bug free and does what you intended them to.

I will try to compile an example and instructions on how to use LassoApps instead of LassoStartup. It is a way better solution for storing and accessing custom types and methods. But also requires a few more steps initially.

HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lasso9 take 16: ->substring(start, length)

Carl Ketterling
In reply to this post by Jolle Carlestam-3
> To start with, Cerl, you want my help, you spell my name right.

My apologies, Jolle.  I usually pay particular attention to things like
that.

> You can however put the definitions in a LassoApp and have an _init.lasso page
> that loads the files at startup. This is the way I do it. It does require a
> bit further explanation than I can provide here. I'll try to compile an
> example once I get back to my computer.

I look forward to any examples you can give.


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>