Why this closure fails to compile?

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

Why this closure fails to compile?

GLASS mailing list
'[ :node :dict | 
(node value isSymbol and: [ node value matchesRegex: ''.*oldSelector.*'' ])
  ifTrue: [ 
    dic at: #''oldSelector'' put: node value.
    true ]
  ifFalse: [ false ] 
]' evaluate

???

I don't get it... 
maybe I am too tired...

thanks in advance,

--

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Why this closure fails to compile?

GLASS mailing list
If you look at the CompileError the problem should be clearer (undefined
symbol 'dic') (and yes you are probably tired:):

.        -> anArray( anArray( anArray( 1031, 109, 'undefined symbol',
nil, 'dic')), '[ :node :dict | (node value isSymbol and: [ node value
matchesRege...
..       -> a CompileError occurred (error 1001), compilation errors --
parameter 1 is error descriptor
(class)@ -> Array
(oop)@   -> 392425985
(size)@  -> 2
1@       -> anArray( anArray( 1031, 109, 'undefined symbol', nil, 'dic'))
2@       -> '[ :node :dict | (node value isSymbol and: [ node value
matchesRegex: ''.*oldSelector.*'' ]) ifTrue: [ dic at: #''oldSelector''
put:...



You might want to wrap your #evaluate with something like the following:

[ '[ :node :dict |
(node value isSymbol and: [ node value matchesRegex: ''.*oldSelector.*'' ])
   ifTrue: [
     dic at: #''oldSelector'' put: node value.
     true ]
   ifFalse: [ false ]
]' evaluate ]
     on: CompileError
     do: [ :ex |
       | sourceWithErrors |
       sourceWithErrors := GsMethod
         _sourceWithErrors: ex errorDetails
         fromString:
           ((ex gsArguments at: 2) copyReplaceAll: String cr with:
String lf).
       (GsMultiLineTextInteraction
         prompt: 'CompileError'
         template: sourceWithErrors) signal ]

To get a better error message ...

Dale

On 11/22/15 8:40 AM, Mariano Martinez Peck via Glass wrote:
> '[ :node :dict |
> (node value isSymbol and: [ node value matchesRegex:
> ''.*oldSelector.*'' ])
>   ifTrue: [
>     dic at: #''oldSelector'' put: node value.
>     true ]
>   ifFalse: [ false ]
> ]' evaluate

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Why this closure fails to compile?

Richard Sargent
Administrator
>> a CompileError occurred (error 1001), compilation errors -- parameter 1 is error descriptor

One of the things in 3.3 (coming soon to a computer near you!) is a change in the default message text. Instead of telling you that a CompileError instance represents compilation errors and where to find what you need to know, the message text will identify the first error. This will greatly improve the CompileError exception's usability!