|
From: Stavros M. <mac...@al...> - 2022-09-05 21:40:28
|
OK, reproduced it! As Oleg mentioned, it's related to using *alias*.
Here's the file
(defun $twenty () 20)
(putprop '$vingt '$twenty 'alias)
(defun simp-thirty (a b c) (declare (ignore a b c)) 30)
(putprop '$thirty 'simp-thirty 'operators)
(putprop '$trente '$thirty 'alias)
And here's the demo. Assume the file is at the path *XXX*.
This works fine with plain old *load*:
(%i1) load("XXX")$
(%i2) [twenty(),vingt(),thirty(),trente()];
(%o2) [20, 20, 30, 30]
But not for *alias *with *autoload*, for either routines or simplifying
functions:
(%i1) display2d:false$ setup_autoload("XXX",twenty)$
(%i3) [twenty(),vingt(),thirty(),trente()];
(%o3) [20,vingt(),30,trente()]
(%i4) [twenty(),vingt(),thirty(),trente()];
(%o4) [20,20,30,30]
On Mon, Sep 5, 2022 at 12:01 PM Stavros Macrakis <mac...@al...>
wrote:
> Hmm. I can't seem to reproduce the problem today.
> I wonder what I was doing wrong yesterday.
>
>
> [image: Muppet Muppet Show GIF - Muppet Muppet Show Gilda Radner GIFs]
>
>
> On Mon, Sep 5, 2022 at 5:41 AM Oleg Nesterov <ol...@re...> wrote:
>
>> On 09/04, Stavros Macrakis wrote:
>> >
>> > For the distinction between evaluation and simplification, see the
>> relevant
>> > manual section <
>> https://maxima.sourceforge.io/docs/manual/maxima_45.html>.
>> >
>> > Basically a *routine *(or evaluating function) *does* something, but a
>> > simplifying function *means* something.
>>
>> Thanks a lot Stavros for your time and your explanation!
>>
>> > Attached please find a simple Lisp file which defines *twenty* as a
>> routine
>> > that returns the number 20, and *thirty *as a simplifying function that
>> > returns 30.
>>
>> Cough, I don't see any attachment in this email ;)
>>
>> Could you please send me this lisp file? I am just curious, I am sure I
>> will
>> learn something new from it.
>>
>> > I'm not quite sure why it works the *second* time with *%solve*,
>> > though....
>>
>> Because it is an alias? let me quote my previous email:
>>
>> > > $ cat /tmp/test.mac
>> > > f(x) := x + 1;
>> > >
>> > > alias(g, f);
>> > >
>> > > $ maxima -q
>> > > (%i1) setup_autoload("/tmp/test.mac", g);
>> > > (%o1) done
>> > > (%i2) g(0);
>> > > (%o2) g(0)
>> > > (%i3) g(0);
>> > > (%o3) 1
>>
>>
>> And with this patch
>>
>> --- a/share/to_poly_solve/to_poly_solve.mac
>> +++ b/share/to_poly_solve/to_poly_solve.mac
>> @@ -13,7 +13,7 @@
>> You should have received a copy of the GNU General Public
>> License
>> along with this program. If not, see <
>> http://www.gnu.org/licenses/>. */
>>
>>
>> -eval_when(translate,declare_translated(to_poly_solve,to_poly_solve_h,
>> safer_subst,
>> +eval_when(translate,declare_translated(%solve,to_poly_solve_h,
>> safer_subst,
>> merge_solutions, solution_subst,lambertify, catch_easy_cases,
>> expunge_nonrelevant_cnds));
>>
>> /* Conditionally load to_poly (version 2 or later), grobner,
>> lrats, opsubst, unwind_protect,
>> @@ -389,7 +389,7 @@ lambertify(e,vars) := block([ee, eee, expargs
>> : set(), cexpargs, nexpargs,
>>
>> [e, subs]);
>>
>> -alias(%solve, to_poly_solve);
>> +alias(to_poly_solve, %solve);
>>
>> simp_%solve(e,v,[extraargs]) := block([vc, all_vars, sol,
>> solvedomain, parameter_list,
>> algexact : assoc('algexact,extraargs,true),
>>
>> setup_autoload("to_poly_solve", %solve) works as expected,
>>
>> (%i1) setup_autoload("to_poly_solve", %solve);
>> (%o1) done
>> (%i2) %solve(x=0,x);
>> (%o2) %union([x = 0])
>>
>> but:
>> (%i1) setup_autoload("to_poly_solve", to_poly_solve);
>> (%o1) done
>> (%i2) to_poly_solve(x=0,x);
>> (%o2) to_poly_solve(x = 0, x)
>> (%i3) to_poly_solve(x=0,x);
>> (%o3) %union([x = 0])
>>
>> Oleg.
>>
>>
|