On 02/03/2015 02:09 AM, Waldek Hebisch wrote:
> Ralf Hemmecke wrote:
>>
>> Obviously, argscript now yields something that is equivalent to function
>> application.
> 
> Hmm, argscript always was supposed to behave like function application.

Ah, oh. Mistakingly I thought argscript was from OutputForm, but it's
implemented in Symbol.

> The difference is that now this is handled during coercion to
> OutputForm in Symbol.  Previously this was done by outputTran.

Now it's much better.

> BTW: We have to handle scripted symbols in Symbol, because this
> is the only place where we can reliably distinguish scripted
> symbols from some weird Lisp s-expression which is similar
> to our representation of scripted symbols.

Hmmm.... in OutputForm it says...

        scripts : (%, List %) -> %
            ++ \spad{scripts(f, [sub, super, presuper, presub])}
            ++  creates a form for f with scripts on all 4 corners.

>From which I would never dare to hand that function a list with less
than 4 elements.

(But your new implementation seems to rely on that feature.)

In fact, looking at the implementation, it does the right job when
called with less elements. The docstring should be improved.

Or maybe we rather introduce

  scripts(f, sub)
  scripts(f, sub, super)
  scripts(f, sub, super, presuper)
  scripts(f, sub, super, presuper, presub)

In general I don't like if List is misused. Here one can call that
function with a list that has more than 4 elements. The docstring says
nothing whether such a call will succeed or yield an error. :-(

Your implementation of coerce: % -> OutputFom in Symbol
https://github.com/fricas/fricas/blob/master/src/algebra/symbol.spad#L101
has something like this...

    rsl : List(L) := [ss.presub, ss.presup, ss.sup, ss.sub]
    for si in rsl repeat
         empty?(sl) and empty?(si) => "iterate"
         se :=
             #si = 1 => first(si)
             commaSeparate(si)
         sl := cons(se, sl)
    x0 := outputForm(name(x) pretend Symbol)
    x1 :=
         #sl = 1 => sub(x0, first(sl))
         scripts(x0, sl)

but wouldn't it be simpler to have

    rsl : List(L) := [ss.sub, ss.sup, ss.presup, ss.presub]
    sl: List L := [commaSeparate z for z in rsl | not empty? z
    x0 := outputForm(name(x) pretend Symbol)
    x1 := scripts(x0, sl)

There is no need to single out the one-element cases here, because
OutputForm must handle something like commaSeparate([x]) correctly,
anyway. And (scripts$OutputForm)(a, l) is equivalent to
sub(a, first l) if the l has only one element.

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to