Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should probably implement add, mul, etc. as objects that can be applied to one or more arguments. #33

Open
nikololiahim opened this issue Jun 29, 2021 · 1 comment

Comments

@nikololiahim
Copy link
Collaborator

As this example from here suggests:

[r] > circle
  mul 2 3.14 r > perimeter
  mul 3.14 r r > area

@eyihluyc
Copy link
Member

eyihluyc commented Jul 6, 2021

There are (at least) two approaches:

  1. 'xslt magic':
    For example, the program
[r] > circle
  r.mul 2 3.14 > circumference

with XML representation

<o name="circle">
  <o name="r"/>
  <o base=".mul" name="circumference">
      <o base="r"/>
      <o base="int" data="int">2</o>
      <o base="float" data="float">3.14</o>
  </o>
</o>

is preprocessed to yield

<o name="circle">
  <o name="r"/>
  <o base=".mul" name="circumference">
      <o base=".mul"
          <o base="r"/>
          <o base="int" data="int">2</o>
      </o>
      <o base="float" data="float">3.14</o>
  </o>
</o>

and nothing is to be changed in python runtime.
Probably, this is an easier alternative, and the idea would be that addition/multiplication/conjunction/disjunction are binary operations and support of multiple arguments is rather syntactic sugar.

  1. NumberOperation for .add and .mul (as well as yet non-existent .and and .or for Boolean) gets varargs (or some variation of it, for we would need to forbid 0 arguments) as input.
    This approach seems to be another viable response to the mentioned example. Moreover, there exist other atoms that require varargs (e.g. Sprintf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants