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

ulam cube support #28

Open
belisarius222 opened this issue Aug 31, 2023 · 1 comment
Open

ulam cube support #28

belisarius222 opened this issue Aug 31, 2023 · 1 comment

Comments

@belisarius222
Copy link
Contributor

belisarius222 commented Aug 31, 2023

          nice. What's the thinking on not having "cube"s?

Originally posted by @tinnus-napbus in #27 (review)

This issue is for discussing this question.

@belisarius222 belisarius222 changed the title ulam ulam cube support Aug 31, 2023
@belisarius222
Copy link
Contributor Author

The argument against including cubes is that from ulam's perspective, there's no difference between them and non-singleton atoms. There are a couple arguments in favor of including them, though.

One argument is just that they're valid Hoon literal syntax, and a common syntax at that, so it would be more convenient for programmers to include them -- they won't have to remember that there's a special case of atom literal that isn't supported in ulam.

For strings, %foo saves a character over 'foo'. That's nice if you're typing them all the time.

I think the strongest argument in favor of including cubes in ulam would be if there's a way to use them to encode $% values in a way that preserves the intent, i.e. some way to make it clear from reading the ulam syntax that the value came from a $% where the cube is the tag.

There is some similarity here between ulam's %page type and a $%. The $page could be thought of as a special case of a $%, but where the tagged value is just a raw noun. It's notable that ulam can encode raw nouns already, as $coin literals, so it's not clear we need special functionality for %pages.

Instead, we could have ulam syntax for $% tagged by cube, where the tagged value is itself an ulam. This could reuse the existing Hoon irregular syntax foo+val, which in Hoon is a shortcut for [%foo val].

{
  ~zod: 0x0,
  ~bus: foo+0x1
}
::
^-  ulam
:-  %map
%-  gas:((on ulam ulam) lte-ulam)
:~  [[%coin %$ %p ~zod] [%coin $% %ux 0x0]]
    [[%coin %$ %p ~bus] [%bccn [%tas %foo] %coin %$ %ux 0x1]]
==

The syntax could be extended to something like "tall form" in ulam by allowing whitespace after the +.

foo+
[0x0 0x1]
::
^-  ulam
[%bccn [%tas %foo] [%list [%coin %$ %ux 0x0] [%coin %$ %ux 0x1] ~]]]

As for inferring that the cube could be a mark tag, I could see two options: one is to have a different syntax for something we expect to be a page, such as foo/ instead of foo+. The other option, which I think I prefer, is to treat any %bccn as a potential mark tag. Data inside the tag could be mark-converted from ulam to that mark, and if the tagged ulam is a raw noun %coin, then the mark converter would convert from the %noun mark to the specified mark.

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

1 participant