"dynamic message sends"

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

"dynamic message sends"

tty

My apologies if this is old-hat, I have been away from Smalltalk for several years...

I would like to translate this:


html tbsAlert 
beSuccess;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
html tbsAlert 
beInfo;
with: [ html strong: 'Heads up!'. html text: ' This alert needs your attention, but it''s not super important.' ].

html tbsAlert 
beWarning;
with: [ html strong: 'Warning!'. html text: ' Best check yo self, you''re not looking too good.' ].
html tbsAlert 
beDanger;
with: [ html strong: 'Oh snap!'. html text: ' Change a few things up and try submitting again.' ].
 

into something like this:



|tuple|

tuple:= #(beSuccess beInfo beWarning beDanger)

tuple do: [:m
      html tbsAlert 
m;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
]

suggestions appreciated, thx


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: "dynamic message sends"

jgfoster
Hi ‘gettimothy’:

The immediate answer to your question is to use #’perform:’ like this:
html tbsAlert
perform: m;
with: [ … ].
Note, however, that use of #’perform:’ is frowned-upon in some circles and you might be encouraged to find a more “object-oriented” way to do this. 

James

On Mar 17, 2018, at 7:42 PM, gettimothy <[hidden email]> wrote:


My apologies if this is old-hat, I have been away from Smalltalk for several years...

I would like to translate this:


html tbsAlert 
beSuccess;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
html tbsAlert 
beInfo;
with: [ html strong: 'Heads up!'. html text: ' This alert needs your attention, but it''s not super important.' ].

html tbsAlert 
beWarning;
with: [ html strong: 'Warning!'. html text: ' Best check yo self, you''re not looking too good.' ].
html tbsAlert 
beDanger;
with: [ html strong: 'Oh snap!'. html text: ' Change a few things up and try submitting again.' ].
 

into something like this:



|tuple|

tuple:= #(beSuccess beInfo beWarning beDanger)

tuple do: [:m
      html tbsAlert 
m;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
]

suggestions appreciated, thx

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
tty
Reply | Threaded
Open this post in threaded view
|

Re: "dynamic message sends"

tty
James,

Thank you. 

---- On Sat, 17 Mar 2018 23:13:09 -0400 James Foster<[hidden email]> wrote ----
Hi ‘gettimothy’:

The immediate answer to your question is to use #’perform:’ like this:
html tbsAlert
perform: m;
with: [ … ].
Note, however, that use of #’perform:’ is frowned-upon in some circles and you might be encouraged to find a more “object-oriented” way to do this. 

James

On Mar 17, 2018, at 7:42 PM, gettimothy <[hidden email]> wrote:


My apologies if this is old-hat, I have been away from Smalltalk for several years...

I would like to translate this:


html tbsAlert 
beSuccess;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
html tbsAlert 
beInfo;
with: [ html strong: 'Heads up!'. html text: ' This alert needs your attention, but it''s not super important.' ].

html tbsAlert 
beWarning;
with: [ html strong: 'Warning!'. html text: ' Best check yo self, you''re not looking too good.' ].
html tbsAlert 
beDanger;
with: [ html strong: 'Oh snap!'. html text: ' Change a few things up and try submitting again.' ].
 

into something like this:



|tuple|

tuple:= #(beSuccess beInfo beWarning beDanger)

tuple do: [:m
      html tbsAlert 
m;
with: [ html strong: 'Well done!'. html text: ' You successfully read this important alert message.' ].
]

suggestions appreciated, thx

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: "dynamic message sends"

Sean P. DeNigris
Administrator
In reply to this post by jgfoster
jgfoster wrote
> Note, however, that use of #’perform:’ is frowned-upon in some circles and
> you might be encouraged to find a more “object-oriented” way to do this.

Although we don't have much context about the project, I would probably also
just use perform. Unless this is demo code for a presentation about
beautiful OOP ;)



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Cheers,
Sean