Rewrite Assist Needed

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

Rewrite Assist Needed

Boris Popov, DeepCove Labs (SNN)

I’m looking for a rewrite rule for the following abstract construct,

 

(variable := expression) cascade.

 

to transform into,

 

variable := (expression) cascade; yourself.

 

Say,

 

(dict := Dictionary new) at: ‘key’ put: ‘value’.

 

into,

 

dict := (Dictionary new) at: ‘key’ put: ‘value’; yourself.

 

Or,

 

(c := Contact new) name: ‘Ernest’.

 

into,

 

c := (Contact new) name: ‘Ernest’; yourself.

 

I won’t bother pasting my failed attempts at something that works universally purely not to embarrass myself.

 

Regards,

 

-Boris

 

--

DeepCove Labs Ltd.

+1 (604) 689-0322

4th floor, 595 Howe Street

Vancouver, British Columbia

Canada V6C 2T5

http://tinyurl.com/r7uw4

 

PacNet Services (Europe) Ltd.

+353 (0)61 714-360

Shannon Airport House, SFZ

County Clare, Ireland

http://tinyurl.com/y952amr

 

CONFIDENTIALITY NOTICE

 

This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments.

 

Thank you.

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite Assist Needed

Fahey Brian-2

Search For:

`method

            |`@temps|

            `.@stmts.

            (`tempVar := `anObject new) at: `@key put: `@value.

            `.@stmts2.

 

Replace With:

`method

            |`@temps|

            `.@stmts.

            `tempVar := (`anObject new) at: `@key put: `@value; yourself.

            `.@stmts2.

 

 

Method checkbox is checked.

 

 

 

Brian Fahey

JJIS Developer

503-373-7146

 

From: Boris Popov, DeepCove Labs [mailto:[hidden email]]
Sent: Wednesday, September 29, 2010 7:59 AM
To: vwnc
Subject: [vwnc] Rewrite Assist Needed

 

I’m looking for a rewrite rule for the following abstract construct,

 

(variable := expression) cascade.

 

to transform into,

 

variable := (expression) cascade; yourself.

 

Say,

 

(dict := Dictionary new) at: ‘key’ put: ‘value’.

 

into,

 

dict := (Dictionary new) at: ‘key’ put: ‘value’; yourself.

 

Or,

 

(c := Contact new) name: ‘Ernest’.

 

into,

 

c := (Contact new) name: ‘Ernest’; yourself.

 

I won’t bother pasting my failed attempts at something that works universally purely not to embarrass myself.

 

Regards,

 

-Boris

 

--

DeepCove Labs Ltd.

+1 (604) 689-0322

4th floor, 595 Howe Street

Vancouver, British Columbia

Canada V6C 2T5

http://tinyurl.com/r7uw4

 

PacNet Services (Europe) Ltd.

+353 (0)61 714-360

Shannon Airport House, SFZ

County Clare, Ireland

http://tinyurl.com/y952amr

 

CONFIDENTIALITY NOTICE

 

This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments.

 

Thank you.

 



This message is intended for official use and may contain information classified as RESTRICTED or CRITICAL. It should be properly delivered, labeled, stored, and disposed of according to the recipient’s policy. If you are not the intended recipient, please advise me by reply e-mail and immediately delete the message and any attachments from your system.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite Assist Needed

Boris Popov, DeepCove Labs (SNN)
Thanks, I got that far as well, but couldn't figure out how to generalize it further to wildcard any kind of keyword message in the cascade, not just at:put:...
 
-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.


From: Fahey Brian [mailto:[hidden email]]
Sent: Wed 9/29/2010 4:32 PM
To: Boris Popov, DeepCove Labs; vwnc
Subject: RE: [vwnc] Rewrite Assist Needed

Search For:

`method

            |`@temps|

            `.@stmts.

            (`tempVar := `anObject new) at: `@key put: `@value.

            `.@stmts2.

 

Replace With:

`method

            |`@temps|

            `.@stmts.

            `tempVar := (`anObject new) at: `@key put: `@value; yourself.

            `.@stmts2.

 

 

Method checkbox is checked.

 

<IMG id=Picture_x0020_2 src="https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwnc]%20Rewrite%20Assist%20Needed.EML/1_multipart/image001.png" width=511 height=565>

 

<IMG id=Picture_x0020_3 src="https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwnc]%20Rewrite%20Assist%20Needed.EML/1_multipart/image002.png" width=616 height=354>

 

Brian Fahey

JJIS Developer

503-373-7146

 

From: Boris Popov, DeepCove Labs [mailto:[hidden email]]
Sent: Wednesday, September 29, 2010 7:59 AM
To: vwnc
Subject: [vwnc] Rewrite Assist Needed

 

I’m looking for a rewrite rule for the following abstract construct,

 

(variable := expression) cascade.

 

to transform into,

 

variable := (expression) cascade; yourself.

 

Say,

 

(dict := Dictionary new) at: ‘key’ put: ‘value’.

 

into,

 

dict := (Dictionary new) at: ‘key’ put: ‘value’; yourself.

 

Or,

 

(c := Contact new) name: ‘Ernest’.

 

into,

 

c := (Contact new) name: ‘Ernest’; yourself.

 

I won’t bother pasting my failed attempts at something that works universally purely not to embarrass myself.

 

Regards,

 

-Boris

 

--

DeepCove Labs Ltd.

+1 (604) 689-0322

4th floor, 595 Howe Street

Vancouver, British Columbia

Canada V6C 2T5

http://tinyurl.com/r7uw4

 

PacNet Services (Europe) Ltd.

+353 (0)61 714-360

Shannon Airport House, SFZ

County Clare, Ireland

http://tinyurl.com/y952amr

 

CONFIDENTIALITY NOTICE

 

This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments.

 

Thank you.

 



This message is intended for official use and may contain information classified as RESTRICTED or CRITICAL. It should be properly delivered, labeled, stored, and disposed of according to the recipient’s policy. If you are not the intended recipient, please advise me by reply e-mail and immediately delete the message and any attachments from your system.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

image001.png (40K) Download Attachment
image002.png (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite Assist Needed

Niall Ross
Dear Boris,
    if you just want to match two-argument methods then

Search For: (do not check the method box)
           
        (`tempVar := `anObject new) `at: `@key `put: `@value.

Replace With:

        `tempVar := (`anObject new) `at: `@key `put: `@value; yourself.

is sufficient.  If you want to match any number of args, use

Search For: (do not check the method box)
           
        (`tempVar := `anObject new) `@atXputX: `@params.

Replace With:

        `tempVar := (`anObject new) `@atXputX: `@params; yourself.

Generally, when writing rewrite expressions, start by pasting the code
you want to match from an example method and then, character by
character, transform it to metacode, at each change clicking 'Find' to
see whether it still matches (just like running a test).  That way, you
will always know what bit of the metacode does not do what you expect.

HTH.
          Yours faithfully
             Niall Ross

>Thanks, I got that far as well, but couldn't figure out how to generalize it further to wildcard any kind of keyword message in the cascade, not just at:put:...
>
>-Boris
>
>--
>+1.604.689.0322
>DeepCove Labs Ltd.
>4th floor 595 Howe Street
>Vancouver, Canada V6C 2T5
>
>[hidden email]
>
>CONFIDENTIALITY NOTICE
>
>This email is intended only for the persons named in the message
>header. Unless otherwise indicated, it contains information that is
>private and confidential. If you have received it in error, please
>notify the sender and delete the entire message including any
>attachments.
>
>Thank you.
>
>________________________________
>
>From: Fahey Brian [mailto:[hidden email]]
>Sent: Wed 9/29/2010 4:32 PM
>To: Boris Popov, DeepCove Labs; vwnc
>Subject: RE: [vwnc] Rewrite Assist Needed
>
>
>
>Search For:
>
>`method
>
>            |`@temps|
>
>            `.@stmts.
>
>            (`tempVar := `anObject new) at: `@key put: `@value.
>
>            `.@stmts2.
>
>
>
>Replace With:
>
>`method
>
>            |`@temps|
>
>            `.@stmts.
>
>            `tempVar := (`anObject new) at: `@key put: `@value; yourself.
>
>            `.@stmts2.
>
>
>
>
>
>Method checkbox is checked.
>
>
>
> <https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwnc]%20Rewrite%20Assist%20Needed.EML/1_multipart/image001.png>
>
>
>
> <https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwnc]%20Rewrite%20Assist%20Needed.EML/1_multipart/image002.png>
>
>
>
>Brian Fahey
>
>JJIS Developer
>
>503-373-7146
>
>
>
>From: Boris Popov, DeepCove Labs [mailto:[hidden email]]
>Sent: Wednesday, September 29, 2010 7:59 AM
>To: vwnc
>Subject: [vwnc] Rewrite Assist Needed
>
>
>
>I'm looking for a rewrite rule for the following abstract construct,
>
>
>
>(variable := expression) cascade.
>
>
>
>to transform into,
>
>
>
>variable := (expression) cascade; yourself.
>
>
>
>Say,
>
>
>
>(dict := Dictionary new) at: 'key' put: 'value'.
>
>
>
>into,
>
>
>
>dict := (Dictionary new) at: 'key' put: 'value'; yourself.
>
>
>
>Or,
>
>
>
>(c := Contact new) name: 'Ernest'.
>
>
>
>into,
>
>
>
>c := (Contact new) name: 'Ernest'; yourself.
>
>
>
>I won't bother pasting my failed attempts at something that works universally purely not to embarrass myself.
>
>
>
>Regards,
>
>
>
>-Boris
>
>
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>vwnc mailing list
>[hidden email]
>http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>  
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite Assist Needed

Boris Popov, DeepCove Labs (SNN)
Niall,

Thanks, but that only works when there's a single method being sent, but
not when there's a cascade,

http://dl.dropbox.com/u/6265/visualworks/rewrite20100930/1.png
http://dl.dropbox.com/u/6265/visualworks/rewrite20100930/2.png

What is the most up-to-date resource on the rewrite rules out there for
me to dig into?

Regards,

-Boris

--
DeepCove Labs Ltd.
+1 (604) 689-0322
4th floor, 595 Howe Street
Vancouver, British Columbia
Canada V6C 2T5
http://tinyurl.com/r7uw4

PacNet Services (Europe) Ltd.
+353 (0)61 714-360
Shannon Airport House, SFZ
County Clare, Ireland
http://tinyurl.com/y952amr

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: Niall Ross [mailto:[hidden email]]
Sent: 29 September 2010 18:41
To: Boris Popov, DeepCove Labs
Cc: vwnc
Subject: Re: [vwnc] Rewrite Assist Needed

Dear Boris,
    if you just want to match two-argument methods then

Search For: (do not check the method box)
           
        (`tempVar := `anObject new) `at: `@key `put: `@value.

Replace With:

        `tempVar := (`anObject new) `at: `@key `put: `@value; yourself.

is sufficient.  If you want to match any number of args, use

Search For: (do not check the method box)
           
        (`tempVar := `anObject new) `@atXputX: `@params.

Replace With:

        `tempVar := (`anObject new) `@atXputX: `@params; yourself.

Generally, when writing rewrite expressions, start by pasting the code
you want to match from an example method and then, character by
character, transform it to metacode, at each change clicking 'Find' to
see whether it still matches (just like running a test).  That way, you
will always know what bit of the metacode does not do what you expect.

HTH.
          Yours faithfully
             Niall Ross

>Thanks, I got that far as well, but couldn't figure out how to
generalize it further to wildcard any kind of keyword message in the
cascade, not just at:put:...

>
>-Boris
>
>--
>+1.604.689.0322
>DeepCove Labs Ltd.
>4th floor 595 Howe Street
>Vancouver, Canada V6C 2T5
>
>[hidden email]
>
>CONFIDENTIALITY NOTICE
>
>This email is intended only for the persons named in the message
>header. Unless otherwise indicated, it contains information that is
>private and confidential. If you have received it in error, please
>notify the sender and delete the entire message including any
>attachments.
>
>Thank you.
>
>________________________________
>
>From: Fahey Brian [mailto:[hidden email]]
>Sent: Wed 9/29/2010 4:32 PM
>To: Boris Popov, DeepCove Labs; vwnc
>Subject: RE: [vwnc] Rewrite Assist Needed
>
>
>
>Search For:
>
>`method
>
>            |`@temps|
>
>            `.@stmts.
>
>            (`tempVar := `anObject new) at: `@key put: `@value.
>
>            `.@stmts2.
>
>
>
>Replace With:
>
>`method
>
>            |`@temps|
>
>            `.@stmts.
>
>            `tempVar := (`anObject new) at: `@key put: `@value;
yourself.

>
>            `.@stmts2.
>
>
>
>
>
>Method checkbox is checked.
>
>
>
> <https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwn
> c]%20Rewrite%20Assist%20Needed.EML/1_multipart/image001.png>
>
>
>
> <https://yvr.pacnetservices.com/exchange/boris.popov/Drafts/RE:%20[vwn
> c]%20Rewrite%20Assist%20Needed.EML/1_multipart/image002.png>
>
>
>
>Brian Fahey
>
>JJIS Developer
>
>503-373-7146
>
>
>
>From: Boris Popov, DeepCove Labs [mailto:[hidden email]]
>Sent: Wednesday, September 29, 2010 7:59 AM
>To: vwnc
>Subject: [vwnc] Rewrite Assist Needed
>
>
>
>I'm looking for a rewrite rule for the following abstract construct,
>
>
>
>(variable := expression) cascade.
>
>
>
>to transform into,
>
>
>
>variable := (expression) cascade; yourself.
>
>
>
>Say,
>
>
>
>(dict := Dictionary new) at: 'key' put: 'value'.
>
>
>
>into,
>
>
>
>dict := (Dictionary new) at: 'key' put: 'value'; yourself.
>
>
>
>Or,
>
>
>
>(c := Contact new) name: 'Ernest'.
>
>
>
>into,
>
>
>
>c := (Contact new) name: 'Ernest'; yourself.
>
>
>
>I won't bother pasting my failed attempts at something that works
universally purely not to embarrass myself.

>
>
>
>Regards,
>
>
>
>-Boris
>
>
>
>  
>
>-----------------------------------------------------------------------
>-
>
>_______________________________________________
>vwnc mailing list
>[hidden email]
>http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>  
>



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite Assist Needed

Niall Ross
Dear Boris,
    although

Search for:
    (`var := Dictionary new) `;@atXputX: `@params.

will match what you want, you cannot then write

Replace with:
    `var := Dictionary new `;@atXputX: `@params; yourself.

It will DNU.  The problem is partly that the meta-language is not
expressive enough to say what you want and partly you are trying to
replace the outer cascade with the inner assignment and the tool is not
expecting that.  Use the tool's block notation:

Search for:
    `{:node :dict |
    node isCascade
    and: [node receiver isAssignment
    and: [node receiver value formattedCode = 'Dictionary new'
    and: [dict at: #myKey put: node. true]]]}

Replace with:
    `{:dict || cascadeNode assignNode |
    cascadeNode := (dict at:  #myKey) copy.
    assignNode := cascadeNode receiver.
    cascadeNode messages do: [:each | each receiver: assignNode value].
    assignNode value: cascadeNode.
    cascadeNode messages add: (RBMessageNode receiver: cascadeNode
receiver selector: #yourself).
    assignNode}

Notes
====
1) The above would be a bit simpler if you have the custom refactoring
project's rewrite tool tweaks to hand.  They are available in 7.5 and
earlier and if yiu want to add you voice to those at ESUG who asked for
them to be ported forward (and considered for the base), please be my
guest.  (And ditto re an update to the tool's usage documentation.)

2) We copy the cascade to prevent an endless loop.  We replace the
matched cascade node with the value of the block, i.e. the assign node,
which we make the parent of the cascade node we have set up within the
block.  Thus if that were the original cascade node, the assign node
would end up being its own parent.

HTH.
             Yours faithfully
                Niall Ross




>Niall,
>
>Thanks, but that only works when there's a single method being sent, but
>not when there's a cascade,
>
>http://dl.dropbox.com/u/6265/visualworks/rewrite20100930/1.png
>http://dl.dropbox.com/u/6265/visualworks/rewrite20100930/2.png
>
>What is the most up-to-date resource on the rewrite rules out there for
>me to dig into?
>
>Regards,
>
>-Boris
>
>  
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc