Re: Make port optional when there’s only one possibility?

As you say, unnamed ports could always default to the primary port. The
primary port is usually "source", but not always, and this way you don't
have to look it up in case you forget. In some cases it might also make
refactoring and debugging easier.

You could take it a step further and say that even when you declare a step,
a primary port doesn't need to have a name. They're usually named "source"
and "result" anyway, so it's mostly boilerplate.

Hmm, maybe the default names for primary input/output could be
source/result?

Regards
Jostein

On 23 September 2017 at 10:31, Norman Walsh <ndw@nwalsh.com> wrote:

> 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 Monday, 25 September 2017 09:42:59 UTC