gwpatrick

25 Reputation

3 Badges

12 years, 252 days

MaplePrimes Activity


These are answers submitted by gwpatrick

This works:

sed -e'1i interface(screenwidth=1000,warnlevel=0,indentamount=2);proc()' -e'$a end;' ugly.maple | maple -q | sed -e'1,4d' -e'$d' | sed -e'$d' | sed -e'$a ;' | sed -e's/^  //' > nice.maple

It wraps the module into a proc and then maple prints that. Deletes the first few lines so removing the proc, and the end proc at the end, inserts a ; and deletes two leading blanks of indentation from the wrapper proc.

except that references to static variables in the module are replaced by things like LOC[4].

 

Saftey tip (?): don;t use variables called LOC.


>See ?object,methods for more information

What it says:

>To call a method that is exported by an object, use the standard
>function calling syntax with the object as an argument.  When
>evaluating the function call, Maple will search the arguments, left to
>right, for an object that exports a method with the same name as the
>specified function.  The first object found with a matching method
>will have its method called with the given arguments.

What it might better say:

>To call a method that is exported by an object,
** you can use the name qualified by that object and :-, as in obj:-method.
** If you omit the obj:- qualifier, then Maple will resolve the call as
** follows: first,
> Maple will search the arguments, left to
>right, for an object that exports a method with the same name as the
>specified function.  The first object found with a matching method
>will have its method called with the given arguments.
** If no such method is found, then Maple will search for a global
** procedure with the same name.

This is consistent with:


module AAAA() option object;
  export foo := proc() print("AAAA foo") end proc; end module;
module BBBB() option object;
  export foo := proc() print("BBBB foo") end proc; end module;
foo:=proc() print("GLOBAL foo") end proc;

foo(AAAA);                      #"AAAA foo"
foo(BBBB);                      #"BBBB foo"
foo();                          #"GLOBAL foo"
foo(AAAA,BBBB);                 #"AAAA foo"
foo(BBBB,AAAA);                 #"BBBB foo"
AAAA:-foo(BBBB);                #"AAAA foo"
BBBB:-foo(AAAA);                #"BBBB foo"
foo(AAAA,BBBB);                 #"AAAA foo"
foo(BBBB,AAAA);                 #"BBBB foo"
foo(1,2,3,AAAA);                #"AAAA foo"
BBBB:-foo(1,2,3,AAAA);          #"BBBB foo"


A question is, in the case of nested classes where the method is
called unqualified, what does Maple do? Search from the innermost
outward (an enclosing class could have foo, and there could be a
global foo)? Also, can one partially qualify a name and then it stops
the search at the partial qualification?

BTW, in ?:= it says

>The ":-" operator can also be used as a unary, prefix operator, whose
>sole operand is a symbol. The expression :-sym evaluates to the
>global instance of sym, even if there is a local binding for sym in
>scope.

but

:=foo(AAAA)            #"AAAA foo"

and it didn't get the global one as apparently promised by ?:=


Page 1 of 1