DO NOT DO THIS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

DO NOT DO THIS

Richard Sargent
Administrator
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

John O'Keefe-3
Richard -

Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ #() ] ].

John

On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

John O'Keefe-3
Richard -

The patch actually fixes implementorsOf:, not sendersOf:. Make the same change in EmSystemConfiguration>>#findSelectorUsing:ifCancel: to fix sendersOf:.

John

On Thursday, March 27, 2014 4:30:18 PM UTC-4, John O'Keefe wrote:
Richard -

Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ #() ] ].

John

On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

John O'Keefe-3
In reply to this post by Richard Sargent
I will be a little more clever with the actual fix since this patch is broken if we ever allow binary selectors with more and 2 characters and you implement #***.

On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

John O'Keefe-3
In reply to this post by John O'Keefe-3
Richard -

This patch actually fixed implementorsOf:, not sendersOf:. Change the first 2 statements in EmSystemConfiguration>>#findSelectorUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ nil ] ].

John

On Thursday, March 27, 2014 4:30:18 PM UTC-4, John O'Keefe wrote:
Richard -

Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ #() ] ].

John

On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

Richard Sargent
Administrator
Thanks, John. However, I don't think this is the complete solution either. The problem also exists when I am browsing the class with the #** implementation, and ask for the senders of that method.

Your change should also duplicate the special case for the single asterisk.
    aString = '*' ifTrue: [^#*].    "Treat '*' as the multiply selector."  "$NON-NLS$"
    aString = '**' ifTrue: [^#**].    "Treat '**' as an infix selector."  "$NON-NLS$"


There are multiple parts to the problem. Asking for the senders when browsing a specific implementation opens a highlighting methods browser, which at some point selects the first method in the list of senders and attempts to highlight the pattern. The EtTextHighlighter never stops. For a method with 418 bytes of source code, the positions instance variable contains OrderedCollection(1 @ 418 2 @ 418 3 @ 418 4 @ 418 5 @ 418 6 @ 418  ...etc...). I broke it at 1.3 million entries already "pattern matched".

(When I wrote my original post, I hadn't considered the attempt to browse from the Transcript's Tool menu. Tools/Implementors takes about 30 seconds to present the list of selectors to choose from, after which finding the specific implementor is essentially instant.)

As a secondary point, it would be nice if one could use the Find/Replace dialogue to locate a number sign or an asterisk in the text pane. Definitely a feature request, not a bug report.



On Thursday, March 27, 2014 1:53:36 PM UTC-7, John O'Keefe wrote:
Richard -

This patch actually fixed implementorsOf:, not sendersOf:. Change the first 2 statements in EmSystemConfiguration>>#findSelectorUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ nil ] ].

John

On Thursday, March 27, 2014 4:30:18 PM UTC-4, John O'Keefe wrote:
Richard -

Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSymbol ]
ifFalse: [ ^ #() ] ].

John

On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


Instantiations, if you would like to correct what happens if you do, please feel free! :-)

(By the way, I believe the underlying error occurs from other means as well.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DO NOT DO THIS

John O'Keefe-3
Richard -

I'm not sure I understand your point. My solution does handle the special case of a single asterisk in the first line of code: (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ]).

I think that if you change the 2nd line of EtTextHighlighter>>#match:from:to:with:from:to: with this:

(wildIndex = 0 or: [ aString allSatisfy: [ :ea | ea = $* ] ])   ifTrue: [

your problem with highlighting will be fixed.

I promised a patch that would handle binary selectors of more than 2 characters (i.e. #***), and so here it is:

Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString anySatisfy: [ :ea | ea ~= $* ] ])
or: [ aString includes: $# ]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ Array with: aString asSelector ]
ifFalse: [ ^ #() ] ].

Change the first 2 statements of EmSystemConfiguration>>#findSelectorsUsing:ifCancel: to

(((aString includes: $*) and: [ aString anySatisfy: [ :ea | ea ~= $* ] ])
or: [ aString includes: $# ]) ifFalse: [  "Not a wildcard"
(Symbol symbolTable includes: aString)
ifTrue: [ ^ aString asSymbol ]
ifFalse: [ ^ nil ] ].

I found 3 more methods that need changing: EmSystemConfiguration>>#stsFindMultipleSelectorsUsing:ifCancel, #stsFindSelectorsUsing:ifCancel:, and #sysFindSelectorUsing:ifCancel. Change then as above (the difference is they use StsPowerTools symbolTable rather than Symbol symbolTable in the 3rd line).

And here is my testcase: 
  1. Create Number>>#** as syntactic sugar for #raiseTo:
  2. Change ScaledDecimal>>#* to use #** instead of #raiseTo: (2 places)
StsClassBrowser
    1. Browse the Number class and select the ** method
    2. Use RMB to select Browse Senders->Local  "OK - none"
    3. Use RMB to select Browse Senders->All  "OK - one"
    4. Use RMB to select Browse Implementors->Local  "OK - one"
    5. Use RMB to select Browse Implementors->All  "OK - one"
    System Transcript
    1. Tools->Browse Senders..., enter ** in the Senders of? popup  "OK - one"
    2. Tools->Browse Implementors..., enter ** in the Implementors of? popup  "OK - one"
    Is there some other path that is getting you to bad handling of #** when the patches in this post art applied?

    John

    On Thursday, March 27, 2014 5:37:58 PM UTC-4, Richard Sargent wrote:
    Thanks, John. However, I don't think this is the complete solution either. The problem also exists when I am browsing the class with the #** implementation, and ask for the senders of that method.

    Your change should also duplicate the special case for the single asterisk.
        aString = '*' ifTrue: [^#*].    "Treat '*' as the multiply selector."  "$NON-NLS$"
        aString = '**' ifTrue: [^#**].    "Treat '**' as an infix selector."  "$NON-NLS$"


    There are multiple parts to the problem. Asking for the senders when browsing a specific implementation opens a highlighting methods browser, which at some point selects the first method in the list of senders and attempts to highlight the pattern. The EtTextHighlighter never stops. For a method with 418 bytes of source code, the positions instance variable contains OrderedCollection(1 @ 418 2 @ 418 3 @ 418 4 @ 418 5 @ 418 6 @ 418  ...etc...). I broke it at 1.3 million entries already "pattern matched".

    (When I wrote my original post, I hadn't considered the attempt to browse from the Transcript's Tool menu. Tools/Implementors takes about 30 seconds to present the list of selectors to choose from, after which finding the specific implementor is essentially instant.)

    As a secondary point, it would be nice if one could use the Find/Replace dialogue to locate a number sign or an asterisk in the text pane. Definitely a feature request, not a bug report.



    On Thursday, March 27, 2014 1:53:36 PM UTC-7, John O'Keefe wrote:
    Richard -

    This patch actually fixed implementorsOf:, not sendersOf:. Change the first 2 statements in EmSystemConfiguration>>#findSelectorUsing:ifCancel: to

    (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
    or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
    (Symbol symbolTable includes: aString)
    ifTrue: [ ^ Array with: aString asSymbol ]
    ifFalse: [ ^ nil ] ].

    John

    On Thursday, March 27, 2014 4:30:18 PM UTC-4, John O'Keefe wrote:
    Richard -

    Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

    Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

    (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
    or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
    (Symbol symbolTable includes: aString)
    ifTrue: [ ^ Array with: aString asSymbol ]
    ifFalse: [ ^ #() ] ].

    John

    On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
    Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


    Instantiations, if you would like to correct what happens if you do, please feel free! :-)

    (By the way, I believe the underlying error occurs from other means as well.)

    --
    You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
    To post to this group, send email to [hidden email].
    Visit this group at http://groups.google.com/group/va-smalltalk.
    For more options, visit https://groups.google.com/d/optout.
    Reply | Threaded
    Open this post in threaded view
    |

    Re: DO NOT DO THIS

    John O'Keefe-3
    In reply to this post by Richard Sargent
    Richard -

    Yes, I can see that it would be convenient for the Find/Replace dialog to treat a single # or * as a character rather than a wildcard. I'll open a feature request for this.

    John

    On Thursday, March 27, 2014 5:37:58 PM UTC-4, Richard Sargent wrote:
    Thanks, John. However, I don't think this is the complete solution either. The problem also exists when I am browsing the class with the #** implementation, and ask for the senders of that method.

    Your change should also duplicate the special case for the single asterisk.
        aString = '*' ifTrue: [^#*].    "Treat '*' as the multiply selector."  "$NON-NLS$"
        aString = '**' ifTrue: [^#**].    "Treat '**' as an infix selector."  "$NON-NLS$"


    There are multiple parts to the problem. Asking for the senders when browsing a specific implementation opens a highlighting methods browser, which at some point selects the first method in the list of senders and attempts to highlight the pattern. The EtTextHighlighter never stops. For a method with 418 bytes of source code, the positions instance variable contains OrderedCollection(1 @ 418 2 @ 418 3 @ 418 4 @ 418 5 @ 418 6 @ 418  ...etc...). I broke it at 1.3 million entries already "pattern matched".

    (When I wrote my original post, I hadn't considered the attempt to browse from the Transcript's Tool menu. Tools/Implementors takes about 30 seconds to present the list of selectors to choose from, after which finding the specific implementor is essentially instant.)

    As a secondary point, it would be nice if one could use the Find/Replace dialogue to locate a number sign or an asterisk in the text pane. Definitely a feature request, not a bug report.



    On Thursday, March 27, 2014 1:53:36 PM UTC-7, John O'Keefe wrote:
    Richard -

    This patch actually fixed implementorsOf:, not sendersOf:. Change the first 2 statements in EmSystemConfiguration>>#findSelectorUsing:ifCancel: to

    (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
    or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
    (Symbol symbolTable includes: aString)
    ifTrue: [ ^ Array with: aString asSymbol ]
    ifFalse: [ ^ nil ] ].

    John

    On Thursday, March 27, 2014 4:30:18 PM UTC-4, John O'Keefe wrote:
    Richard -

    Ha, ha -- wildcard search string runs forever (or at least until you hit the break button).

    Change the first 2 statements of EmSystemConfiguration>>#findMultipleSelectorsUsing:ifCancel: to

    (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ])  "$NON-NLS$"  "$NON-NLS$"
    or: [aString includes: $#]) ifFalse: [  "Not a wildcard"
    (Symbol symbolTable includes: aString)
    ifTrue: [ ^ Array with: aString asSymbol ]
    ifFalse: [ ^ #() ] ].

    John

    On Wednesday, March 26, 2014 5:30:52 PM UTC-4, Richard Sargent wrote:
    Do not create an implementation of ** to mimic functionality in another Smalltalk dialect and then ask for senders of the selector. It's really not a good idea.


    Instantiations, if you would like to correct what happens if you do, please feel free! :-)

    (By the way, I believe the underlying error occurs from other means as well.)

    --
    You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
    To post to this group, send email to [hidden email].
    Visit this group at http://groups.google.com/group/va-smalltalk.
    For more options, visit https://groups.google.com/d/optout.
    Reply | Threaded
    Open this post in threaded view
    |

    Re: DO NOT DO THIS

    Richard Sargent
    Administrator
    In reply to this post by John O'Keefe-3
    On Friday, March 28, 2014 11:56:33 AM UTC-7, John O'Keefe wrote:
    I'm not sure I understand your point. My solution does handle the special case of a single asterisk in the first line of code: (((aString includes: $*) and: [ aString ~= '*' and: [ aString ~= '**' ] ]).


    Ah! I missed the implication of that. I was thrown off by the line that followed the code you showed. It was a line that special cased '*' as a multiply operator. I had assumed (silly thing to do, I know) that it remained a required thing. And then I assumed that if it remained necessary, that we would also need one for the double asterisk case.

    The line in question was:
        aString = '*' ifTrue: [^#*].    "Treat '*' as the multiply selector."  "$NON-NLS$"

     
    I think that if you change the 2nd line of EtTextHighlighter>>#match:from:to:with:from:to: with this:

    (wildIndex = 0 or: [ aString allSatisfy: [ :ea | ea = $* ] ])   ifTrue: [

    your problem with highlighting will be fixed.

    Thanks, that should do the trick. I'll test it, but I expect my results will match yours unless I make a mistake.

     
    I promised a patch that would handle binary selectors of more than 2 characters (i.e. #***), and so here it is:

    I have no test case for this, but I think that any binary selector having two successive asterisks will produce the same problem. e.g. #!**
    Once there are ANSI compatible binary selectors, you should include such a test case.

     

    --
    You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
    To post to this group, send email to [hidden email].
    Visit this group at http://groups.google.com/group/va-smalltalk.
    For more options, visit https://groups.google.com/d/optout.
    Reply | Threaded
    Open this post in threaded view
    |

    Re: DO NOT DO THIS

    Richard Sargent
    Administrator
    In reply to this post by John O'Keefe-3
    On Friday, March 28, 2014 11:56:33 AM UTC-7, John O'Keefe wrote:
    I think that if you change the 2nd line of EtTextHighlighter>>#match:from:to:with:from:to: with this:

    (wildIndex = 0 or: [ aString allSatisfy: [ :ea | ea = $* ] ])   ifTrue: [

    your problem with highlighting will be fixed.

    Almost. aString is the source code. aPattern is the search string.

        (wildIndex = 0 or: [ aPattern allSatisfy: [ :ea | ea = $* ] ])   ifTrue: [
     

    --
    You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
    To post to this group, send email to [hidden email].
    Visit this group at http://groups.google.com/group/va-smalltalk.
    For more options, visit https://groups.google.com/d/optout.