Search code examples
stringversionmaple

convert to string in Maple 15


convert(file.ext,string)

gives a different result depending on the Maple's current version in use. In Maple v14 gives "file.ext" but in Maple v15 gives "file . ext" (with spaces before and after the point). Can anybody explain me this? Thanks in advance.


Solution

  • Yes, there is a difference, but more important is that the approach to form the string in this manner is misguided.

    There are no special (delayed) evaluation rules for the command convert, and what that routine sees as the first argument here is the result of the (noncommutating) multiplication of the name file with the name ext. And so that's not really a great way to concatenate to a string, because it's purpose is not to first carefully concatenate.

    There are alternatives. You could concatenate to a single name, and then convert that to a string, or you could concatenate directly to a string (for which the command convert/string is not best).

     # I'm supposing that one does want the name`file` assigned
     file:=myproject:
    
     # Now suppose that one wants the result "myproject.for"
     ext:=`for`:
    
     convert(file.ext,string); # whoops
                      "myproject . `for`"
    
     cat(file,".",ext); # produces the name `myproject.for`
                         myproject.for
    
     convert(%,string);
                        "myproject.for"
    
     sprintf("%a.%s",file,ext);
                        "myproject.for"