On Mon, Oct 1, 2018 at 8:58 AM Simon King <simon.k...@uni-jena.de> wrote:
>
> Hi Dima,
>
> On 2018-09-30, Dima Pasechnik <dimp...@gmail.com> wrote:
> > it was written before optional parameters era in GAP, as far as I know.
> > Anyhow, you can use GAP's PushOptions() and PopOptions() to achieve more or 
> > less
> > the same effect, with a big uglier syntax.
>
> "Uglier" only internally. I think it shouldn't be too difficult to
> modify libgap's functions so that optional parameters (passed in the
> usual pythonic way) are first pushed and eventually popped from GAP's
> global optional value stack.

Right,  this can all be hidden, and perhaps even implemented with
a decorator (or in some other way?), to avoid manual coding of Push/Pop calls.
Thanks for pointing this out.

>
> When I first saw your work-around, I though it would have ugly side-effects.
> But I just realise that it wouldn't change GAP's behaviour. For instance:
>
>  gap> test := function()
>  >    local foo;
>  >    foo := ValueOption("foo");
>  >    Print(foo);
>  > end;
>  function(  ) ... end
>  gap> f := function()
>  >    local foo;
>  >    foo := ValueOption("foo");
>  >    Print("Original value ",foo);
>  >    test();
>  > end;
>  function(  ) ... end
>  gap> f();
>  Original value failfail
>  gap> f(:foo:=5);
>  Original value 55
>
> Note that the option set when calling the outer function is also present
> in the inner function, and that's the same when directly pushing to the
> global option stack:
>
>  gap> PushOptions(rec(foo:=5));
>  gap> f();
>  Original value 55
>  gap> PopOptions();
>  gap> f();
>  Original value failfail
>
> So, that would work as desired.

Indeed, GAP manual says in its Sect 4.11-2 "Function Call With Options"
that the options syntax is exactly equivalent to using Push/Pop explicitly.

Best,
Dima

>
> Best regards,
> Simon
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to