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

hoon: in +ape:ag, make zero a plain atom #6373

Merged
merged 1 commit into from Mar 15, 2023
Merged

Conversation

Fang-
Copy link
Member

@Fang- Fang- commented Mar 4, 2023

In the +ape parser constructor, we were providing 0 as the parsing result for the zero character. Hoon syntax dictates this is a @ud however, resulting in a parsing output type of ?(@ud etc). Since +ape is commonly used for parsing atoms of various kinds, one might end up with a result of ?(@ud @), which would fail to nest directly under, say, @uv, requiring parsers to add a casting step.

Here, we simply cast the zero result to @ to make it perfectly generic. This should alleviate the need for a casting step in parsers that need to fit their output into a specific aura.

(The output type in the common case (ie, +hex:ag, +viz:ag) is now ?(@ @), which is still somewhat strange, but should have better ergonomics.)

Since @ can be used in any place @ud is accepted, this is a non-breaking change.

In the `+ape` parser constructor, we were providing `0` as the parsing result
for the zero character. Hoon syntax dictates this is a `@ud` however,
resulting in a parsing output type of `?(@ud etc)`. Since `+ape` is commonly
used for parsing atoms of various kinds, one might end up with a result
of `?(@ud @)`, which would fail to nest directly under, say, `@uv`, requiring
parsers to add a casting step.

Here, we simply cast the zero result to `@` to make it perfectly generic. This
should alleviate the need for a casting step in parsers that need to fit their
output into a specific aura.

(The output type in the common case (ie, `+hex:ag`, `+viz:ag`) is now `?(@ @)`,
which is still somewhat strange, but should have better ergonomics.)

Since `@` can be used in any place `@ud` is accepted, this is a non-breaking
change.
@Fang- Fang- added the hoon label Mar 4, 2023
Fang- referenced this pull request in tloncorp/tlon-apps Mar 4, 2023
We specifically wanted to be able to send a dm with `;<ship> <message>` so the first thing the parser attempts after matching a mic is exactly this. Because the `%say` command previously only required a `(list inline:chat)`, and we now need to distinguish between a `%say` command that is directed to a channel we're `viewing` and a dm, outside of the current context, we included a `(unit ship)` within the command.

So the parser then attempts to match a ship and message (found in the `+dm:parser` arm) and builds a `%say` command with the ship if it does. If it's just a `;<ship>` without a message, `+targ` will take over indicating an `audience` change. If there's no `;<ship>` before the message, the text will be passed to `+message` as before, and an empty unit will be put into the `%say` command indicating `+say` should post the message in the current `audience`.

This of course required `$whom` support, so I updated the `+targ` arm to include a `+whom` parser, which uses existing parsers such as `+ship` and `+name`, and a new one (`+club-id`).

I commented out a few non-essential arms/gates which I'll return to fix:
- `+tarl` was commented out since it currently consumes only a `$flag:chat`.
-  `+ships` and `+tars` because I haven't adjust them to support `$whom` yet, and they've aren't currently called anywhere.
- the url parser in `+content` because I was getting an error
@belisarius222 belisarius222 merged commit d81fc6e into develop Mar 15, 2023
2 checks passed
@belisarius222 belisarius222 deleted the m/dumb-apes branch March 15, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants