Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

fixes the macro expansion of $> and $< specs #1176

Merged
merged 1 commit into from
May 25, 2019
Merged

Conversation

joemfb
Copy link
Member

@joemfb joemfb commented May 24, 2019

The expansions of $> and $< were infinitely recursive. These are new specs for building molds from parts of other $% molds. They are ?>-style assertions against the head of the noun being cast or nest-checked. For example:

> `task:able:ames`[%west ~zod /foo 1]
[%west p=~zod q=/foo r=1]
>
> `$>(%west task:able:ames)`[%west ~zod /foo 1]
[%west p=~zod q=/foo r=1]
> 
> `$<(%west task:able:ames)`[%west ~zod /foo 1]
nest-fail

I think it would be very helpful to use these specs when building the +note and +sign molds for vanes, which are obviously subtypes of the +task and +gift types of the other vanes in the system. If there's interest, I'd be happy to do so now.

@joemfb
Copy link
Member Author

joemfb commented May 24, 2019

These specs have some limitations that should be called out explicitly. Most notably, some of them are not directly bunt-able:

> *$<(%west task:able:ames)
[%want p=~zod q=/ r=0]
> *$>(%west task:able:ames)
ford: %ride failed to execute:

This "intuitively" follows from that fact that specs are not available at runtime, but the user-experience is less than intuitive. The ability-to-bunt can be restored (in a frustratingly-explicit nanner) with $~:

> *$~([%west ~zod / 0] $>(%west task:able:ames))
[%west p=~zod q=/ r=0]

As I mentioned, I think the right way to use these specs is in building up a $% that references other specs, like +note and +sign in the vanes. The whole $% should be wrapped in a single $~ to ensure that it bunts, but the individual "pages" of the tagged-union "book" need not be bunt-able.

Copy link
Contributor

@belisarius222 belisarius222 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cgyarvin
Copy link
Contributor

cgyarvin commented May 24, 2019 via email

@joemfb
Copy link
Member Author

joemfb commented May 24, 2019

I think $| is the key for dynamic checks. +map should be something like:

+*  map  [key value]
  $|  (tree (pair @ @))
  |=(a=(tree (pair @ @)) ~(apt by a))

For example:

> ($|((tree (pair @ @)) |=((tree (pair @ @)) ~(apt by +<))) [[1 2] ~ [[3 4] ~ ~]])
{[p=1 q=2] [p=3 q=4]}
> ($|((tree (pair @ @)) |=((tree (pair @ @)) ~(apt by +<))) [[1 2] [[3 4] ~ ~] ~])
ford: %ride failed to execute:

@cgyarvin
Copy link
Contributor

cgyarvin commented May 25, 2019 via email

@cgyarvin
Copy link
Contributor

cgyarvin commented May 25, 2019 via email

Copy link
Contributor

@philipcmonk philipcmonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, very nice. I would like to see the vanes moved to this style soon.

@jtobin jtobin merged commit cf2fa88 into master May 25, 2019
@jtobin jtobin deleted the fix-spec-assertions branch May 25, 2019 07:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants