I have been using Magma for a few weeks now, and all is well except one thing : I can't define my own intrinsics. I have not find that many ressources to learn the language (maybe I can't search...), so I try a lot of things, and right now, I'm stuck on a seemingly simple thing :
I have a file f.m
that contains the following code :
freeze;
a := 1;
function b(n);
return n+1;
end function;
intrinsic c(n::RngIntElt) -> RngIntElt
{meh}
return n+1;
end intrinsic;
and in the Magma console, in the same folder as this file, I've had the following :
> Attach("f.m");
> import "f.m": a,b,c;
> a;
1
> b(1);
2
> c(1);
>> c(1);
^
Runtime error: Symbol 'c' of package "f1.m" not found
I really don't understand what I've done wrong, can anyone enlighten me ?
Ok, after some more reading end experimenting, I don't need to import c
after attaching f.m
.
intrinsics are automatically loaded. This is an important difference with functions and variables defined in a package file with must be explicitly imported. Since this caused me some trouble, I will still upload this question with the solution.
One picture is worth a thousand words, to make this work, simply enter in the console the following :
> Attach("f.m");
> import "f.m": a,b;
> a;
1
> b(1);
2
> c(1);
2
Or in other words, if you don't need the function or the variable, simply don't import anything.