Cascading Messages

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

Cascading Messages

ipstools.project
Hi all,

can't get to operate cascading messages.

There is a class that is created and used with cascading messages by normal message NEW, something like:
AppMessage new id: 123; text 'sample text' .

As I have quite a lot of such  messages, I decided to optimize the creation method to be:
AppMessage id: 123; text 'sample text' .

For that purpose I created a new Class method id:
id: anObject
   ^super new id: anObject


The problem is I get an error message saying  AppMessage class doesn`t understand text, when running new code.
As I believe there is no errors in my code, error still displays. How this can be fixed?

Sergei

--
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 https://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: Cascading Messages

Seth Berman
Hello Sergei,

AppMessage 
   id: 123; 
   text: 'sample text' .

The class object 'AppMessage' is sent the message #id:.
The object returned is a new instance of AppMessage.
But since this is a cascaded expression (due to the ';'), then this
will send the message and drop the result from the top of the stack.
This makes the original receiver (AppMessage), which is now top of stack, the receiver of the next message #text: and so on.
This is desirable because it keeps the receiver from having to be re-pushed to the stack over and over again.

To get your example to work...I believe you just want
(AppMessage id: 123) text: 'sample text'

- Seth

On Wednesday, February 13, 2019 at 12:12:24 PM UTC-5, [hidden email] wrote:
Hi all,

can't get to operate cascading messages.

There is a class that is created and used with cascading messages by normal message NEW, something like:
AppMessage new id: 123; text: 'sample text' .

As I have quite a lot of such  messages, I decided to optimize the creation method to be:
AppMessage id: 123; text: 'sample text' .

For that purpose I created a new Class method id:
id: anObject
   ^super new id: anObject


The problem is I get an error message saying  AppMessage class doesn`t understand text:, when running new code.
As I believe there is no errors in my code, error still displays. How this can be fixed?

Sergei

--
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 https://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: Cascading Messages

ipstools.project
Hi Seth,

I got it (I guess).
In the wrong example the Class AppMessage itself gets the message test: , and using round brackets we make the instance of the class to receive the message.

Thank you.

среда, 13 февраля 2019 г., 20:47:34 UTC+3 пользователь Seth Berman написал:
Hello Sergei,

AppMessage 
   id: 123; 
   text: 'sample text' .

The class object 'AppMessage' is sent the message #id:.
The object returned is a new instance of AppMessage.
But since this is a cascaded expression (due to the ';'), then this
will send the message and drop the result from the top of the stack.
This makes the original receiver (AppMessage), which is now top of stack, the receiver of the next message #text: and so on.
This is desirable because it keeps the receiver from having to be re-pushed to the stack over and over again.

To get your example to work...I believe you just want
(AppMessage id: 123) text: 'sample text'

- Seth

On Wednesday, February 13, 2019 at 12:12:24 PM UTC-5, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_8LkyQUuIQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ipstools...@... wrote:
Hi all,

can't get to operate cascading messages.

There is a class that is created and used with cascading messages by normal message NEW, something like:
AppMessage new id: 123; text: 'sample text' .

As I have quite a lot of such  messages, I decided to optimize the creation method to be:
AppMessage id: 123; text: 'sample text' .

For that purpose I created a new Class method id:
id: anObject
   ^super new id: anObject


The problem is I get an error message saying  AppMessage class doesn`t understand text:, when running new code.
As I believe there is no errors in my code, error still displays. How this can be fixed?

Sergei

--
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 https://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: Cascading Messages

Seth Berman
Hello Sergei,

What you said is exactly right.
My pleasure to help.

- Seth

On Thursday, February 14, 2019 at 9:18:48 AM UTC-5, [hidden email] wrote:
Hi Seth,

I got it (I guess).
In the wrong example the Class AppMessage itself gets the message test: , and using round brackets we make the instance of the class to receive the message.

Thank you.

среда, 13 февраля 2019 г., 20:47:34 UTC+3 пользователь Seth Berman написал:
Hello Sergei,

AppMessage 
   id: 123; 
   text: 'sample text' .

The class object 'AppMessage' is sent the message #id:.
The object returned is a new instance of AppMessage.
But since this is a cascaded expression (due to the ';'), then this
will send the message and drop the result from the top of the stack.
This makes the original receiver (AppMessage), which is now top of stack, the receiver of the next message #text: and so on.
This is desirable because it keeps the receiver from having to be re-pushed to the stack over and over again.

To get your example to work...I believe you just want
(AppMessage id: 123) text: 'sample text'

- Seth

On Wednesday, February 13, 2019 at 12:12:24 PM UTC-5, [hidden email] wrote:
Hi all,

can't get to operate cascading messages.

There is a class that is created and used with cascading messages by normal message NEW, something like:
AppMessage new id: 123; text: 'sample text' .

As I have quite a lot of such  messages, I decided to optimize the creation method to be:
AppMessage id: 123; text: 'sample text' .

For that purpose I created a new Class method id:
id: anObject
   ^super new id: anObject


The problem is I get an error message saying  AppMessage class doesn`t understand text:, when running new code.
As I believe there is no errors in my code, error still displays. How this can be fixed?

Sergei

--
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 https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.