Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
343 stars 230 forks source link

expression of e.g. "image" #325

Closed pzinn closed 4 years ago

pzinn commented 9 years ago

Who hasn't made the following typo: trying to consider the image of a map, say R=QQ[x]; f=matrix{{x}}; one types M=image forgetting f. then immediately corrects it: i4 : M=image f but the output is not what is expected: o4 = { * Function * } | x |

why "{ * Function * }" instead of "image"? apparently when we redefine M, image loses its hasAttribute(image,ReverseDictionary) and therefore its expression becomes { * Function * }.

This is a minor issue, but I'm wondering if it can be easily fixed.

DanGrayson commented 9 years ago

Interesting, thanks!

pzinn commented 6 years ago

more specifically, this can be traced back to

i9 : code Function.GlobalReleaseHook

o9 =  ../pzinn/M2/M2/Macaulay2/m2/last.m2:94:36-97:66: --source code:
Function.GlobalReleaseHook = (X,x) -> (
     if dictionary X =!= User#"private dictionary" then warningMessage(X," redefined");
     if hasAttribute(x,ReverseDictionary) then removeAttribute(x,ReverseDictionary);
     )

to be compared with (note the missing extra condition ===)

i10 : code globalReleaseFunction

o10 =  ../pzinn/M2/M2/Macaulay2/d/startup.m2.in:230:36-235:34: --source code:
     globalReleaseFunction = (X,x) -> (
          if not instance(X,Symbol) then error("globalAssignFunction: expected a symbol: ", toString X);
          if hasAttribute(x,ReverseDictionary)
          and getAttribute(x,ReverseDictionary) === X
          then removeAttribute(x,ReverseDictionary)
          );