Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2t-dev] [MTL] Standard library issues

Arjan,

I really think this flag parameter should be removed from the signature. However I look at it it seems like a way to prevent users from using it accurately. I will implement it as per your last description for the time being.

Laurent Goubet
Obeo

Arjan Kok a écrit :
About the strtok operation: on second thoughts I think you are right.
This is probably a better description:

The strtok() function returns the next token from the string self,
where tokens are strings separated by characters from the string
delimiters. The function should be passed 0 as the value of flagto get
the first token, and 1  to get the subsequent tokens. The function
returns null when there are no more tokens.

2008/8/13 Laurent Goubet <laurent.goubet@xxxxxxx>
  
Hi Arjan,

1) Yup, I think I'll then keep the specification's "substitute" accepting a String, and create a "replace" accepting a regex. Another problem on those is that the specification defines "substitute" to replace "the occurence of the substring". I think we should also add a "substituteAll" if there is more than one occurence of the substring in the target String.

2) & 3) Yes, toUpper() and toLower() are both mentionned in the OCL specification on String.

4) Hum, your explanation doesn't match with the spec as far as we understand it. Specification tells the second parameter of strtok is a flag which will take either 0 (first invocation) or 1 (subsequent invocations). If the explanation you gave here is the expected behavior of the strtok operation, I think the spec should be clarified on it.

Regards,

Laurent Goubet
Obeo

Arjan Kok a écrit :
    
Hi Laurent,

ad 1). Good idea. Perhaps you can make 2 functions, one that accepts a string,and one that accepts a regular _expression_. In that way, you only extend the M2T spec.
ad 2&3). Ok, are you sure they are mentioned in the OCL spec as standard lib functions? Then we probably overlooked them in the OCL spec.
ad 4). strtok is based on the old-style C strtok function. The flag parameter indicates the sequence number of the token.You could use it for example in an iteration.
For example "a$b$c$d".strtok("$",0) returns a, but "a$b$c$d".strtok("$",3) returns d

Regards, Arjan.


2008/8/5 Laurent Goubet <laurent.goubet@xxxxxxx <mailto:laurent.goubet@xxxxxxx>>

   ah, forgot one of the String ones :p.

   4) strtok( String s1, Integer flag ) : String
   Breaks the string self into a sequence of tokens each of which is
   delimited by any character in string s1. The parameter flag should
   be 0 when strtok is called for the first time, 1 subsequently.

   We fail to understand the meaning of the second parameter of this
   method. What did you intend the flag to be used for in the
   implementation? It seems pointless and troublesome to force the
   user to pass 0 or 1 explicitely to this method when he wants to
   make use of it.

   Laurent Goubet
   Obeo

   Laurent Goubet a écrit :

       Hi Arjan,

       I was looking at the specifications as to how the OCL standard
       library has been extended for the needs of MTL and stumbled
       upon a set of issues on which I would need your input. As I
       only began the implementation, I'll only list the issues I
       have with the "String" operations :

       1) substitute( String r, String t ) : String
       Substitutes substring r in self by substring t and returns the
       resulting string. If there is no occurrence of the substring,
       it returns the original string.

       I think it would be nice to tweak the specification so that
       the first parameter would be a regular expresion instead of a
       plain String. I'd love to be able to use an equivalent of the
       Java's "replaceAll" method for MTL Strings.

       2) toUpper() : String
       Creates a copy of self with all characters converted to
       uppercase and returns it.

       This has been listed as a method that should be added to
       "extend the OCL standard library", but this method is
       *already* specified in the OCL specifications for the
       aforementioned library and should be removed from the MTL
       specification.

       3)toLower() : String
       Creates a copy of self with all characters converted to
       lowercase and returns it.

       As above, this is already present in the OCL standard library
       and should probably be removed from the MTL specification.

       I will list more of these issues here as I encounter them
       while implementing the specification.

       Regards

       Laurent Goubet
       Obeo
       _______________________________________________
       m2t-dev mailing list
       m2t-dev@xxxxxxxxxxx <mailto:m2t-dev@xxxxxxxxxxx>
       https://dev.eclipse.org/mailman/listinfo/m2t-dev



   _______________________________________________
   m2t-dev mailing list
   m2t-dev@xxxxxxxxxxx <mailto:m2t-dev@xxxxxxxxxxx>
   https://dev.eclipse.org/mailman/listinfo/m2t-dev


      
_______________________________________________
m2t-dev mailing list
m2t-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2t-dev

    
  

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr/";>Obeo</a>
email;internet:laurent.goubet@xxxxxxx
url:http://www.obeo.fr
version:2.1
end:vcard


Back to the top