Make port optional when there’s only one possibility?

Hello,

This is in a separate message so that there’s the possibility of
keeping it separate from the conversation about input/with-input and
compound steps. :-)

The case of input to for-each and viewport feels a little different
than the case of input to atomic steps. It’s always felt a little
different because compound steps are simultaneously declaring and
defining their inputs. We can say that the input ports are “anonymous”
or “arbitrary”.

In atomic steps, we have to declare them and we have to declare that
they have a port name and then that’s the name that they have, you
don’t get to change it.

So this:

  <p:for-each>
    <p:with-input> … </p:with-input>

feels sort of reasonable. But as I said in the other message, it
introduces a new kind of with-input.

We could, it occurred to me, have a rule that says: if a step has a
single input port, then the port name on p:with-input is optional.

That would allow us to say that p:for-each has a single input port
named source and both of these would be legal:

  <p:for-each>
    <p:with-input> … </p:with-input>

and

  <p:for-each>
    <p:with-input port="source"> … </p:with-input>

This would also become legal:

  <p:identity>
    <p:with-input> … </p:with-input>

I have mixed feelings about this. On the surface it seems reasonable,
but every new variation is something else that has to be explained to
learners.

                                        Be seeing you,
                                          norm

P.S. It would be possible to go even further and say that a
p:with-input that doesn’t name a port is by default the primary input
port, but I think that would be going too far.

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 512 761 6676
www.marklogic.com

Received on Saturday, 23 September 2017 08:32:00 UTC