overriding (adding) operators [message #64728] |
Fri, 28 November 2008 13:14  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------040507080901040102050609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi Christian,
For the purpose of MTL, we often need string concatenation (being a text
generation and all ;)). The "standard" OCL doesn't allow for "simple"
String concatenation, and I wanted to add a "+(String) : String" to the
MTL standard library in order to have something a little more
straightforward than "concat(String) : String".
That didn't work as would any other extension to the standard lib
though. Had I added a "plus(String) : String" operation, I would have
been able to make something like "'te'.plus('st')" ... but this doesn't
add any value as compared to the standard "'te'.concat('st')". What I
need is "'te' + 'st'". As there is no "+" operation defined as a
standard in OCL I would have thought this to be possible. Do you know of
any way to implement such a fonctionnality in the current OCL
implementation?
Laurent Goubet
Obeo
--------------040507080901040102050609
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr/">Obeo</a>
email;internet:laurent.goubet@obeo.fr
url:http://www.obeo.fr
version:2.1
end:vcard
--------------040507080901040102050609--
|
|
|
Re: overriding (adding) operators [message #64751 is a reply to message #64728] |
Fri, 28 November 2008 14:34  |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Laurent,
Knowledge of infix operators like '+' is encoded in the LPG grammar.
OCL's grammar expects numeric values on either side of the '+' operator.
You will have to extend the grammar in a similar way as the various QVT
projects at Eclipse have done. In fact, I think the QVT language also
aliases string concatenation using '+', so I think they will provide an
especially good example for your.
HTH,
Christian
laurent Goubet wrote:
> Hi Christian,
>
> For the purpose of MTL, we often need string concatenation (being a text
> generation and all ;)). The "standard" OCL doesn't allow for "simple"
> String concatenation, and I wanted to add a "+(String) : String" to the
> MTL standard library in order to have something a little more
> straightforward than "concat(String) : String".
>
> That didn't work as would any other extension to the standard lib
> though. Had I added a "plus(String) : String" operation, I would have
> been able to make something like "'te'.plus('st')" ... but this doesn't
> add any value as compared to the standard "'te'.concat('st')". What I
> need is "'te' + 'st'". As there is no "+" operation defined as a
> standard in OCL I would have thought this to be possible. Do you know of
> any way to implement such a fonctionnality in the current OCL
> implementation?
>
> Laurent Goubet
> Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.03052 seconds