Skip to content

Commit

Permalink
Change operator function name syntax from e.g. Int.( * ) to Int.\*
Browse files Browse the repository at this point in the history
This removes the weirdness around needing spaces to avoid comment syntax.
  • Loading branch information
Jason Evans committed Oct 7, 2024
1 parent bf8b32b commit 2bada21
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
10 changes: 5 additions & 5 deletions doc/design/effects_mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ compatible with the interface. Nonetheless, explicit concealed effects present a
can require transitively exposing incidental implementation details. Module interfaces should leave
concealable effects implicit unless functions have legitimate uses in low-level code which requires
complete knowledge of transitive effects, and even then such interfaces should have few, if any,
concealed effects. `Uns.( + )` is a prime practical example.
concealed effects. `Uns.\+` is a prime practical example.

```hemlock
( + ): uns ~-> uns ~-> uns
\+: uns ~-> uns ~-> uns
```

## Partial application
Expand Down Expand Up @@ -593,19 +593,19 @@ call chain is inlined, the precise effect typing enables optimal machine code ge

### Explicit concealed effects

Partial application requires closure allocation. Functions like `Uns.( + )` do not require
Partial application requires closure allocation. Functions like `Uns.\+` do not require
allocation, and because addition is critical functionality in low-level code, the API is explicit
regarding (lack of) concealed effects.

```hemlock
( + ): uns ~-> uns ~-> uns
\+: uns ~-> uns ~-> uns
```

However, if `+` is partially applied, the compiler transforms the function to one with an `alloc`
effect, with signature equivalent to `+*`.

```hemlock
( +* ): uns ~alloc-> (uns ~-> uns)
\+*: uns ~alloc-> (uns ~-> uns)
```

As a consequence, partial application is prohibited within functions like `f`, and allowed within
Expand Down
2 changes: 1 addition & 1 deletion doc/design/work_stealing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The `Array.[map_]reduce[_hlt]` functions also perform recursive binary decomposi
algorithms require no special implementation considerations to be naturally conducive to parallel
execution. Practical examples abound; the following are simple illustrative cases.

- Binary operators like `Uns.( + )` are in principle merges, so work stealing can kick in if the
- Binary operators like `Uns.\+` are in principle merges, so work stealing can kick in if the
inputs are computed via expensive independent continuations. The same is true of any pure function
with two or more independent inputs. If there are more than two non-trivial inputs, the compiler
induces a binary tree structure on the continuations such that at each point where the function
Expand Down
2 changes: 1 addition & 1 deletion ide/kakoune/hemlock.kak
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ add-highlighter shared/hemlock/code/uident regex \b[_]*[a-z][A-Za-z0-9_']*\b 0:D
add-highlighter shared/hemlock/code/tab regex \t 0:Error
add-highlighter shared/hemlock/code/unaligned regex ^(\ \ )*\ (?![\ ]) 0:Error
add-highlighter shared/hemlock/code/unaligned_continue_keyword regex ^(\ \ \ \ )*(and|also|as|else|external|of|or|then|when|with)\b 0:Error
add-highlighter shared/hemlock/code/unaligned_continue_punctuation regex ^(\ \ \ \ )*([\x7D\]),!'\\\-+*/%@$<=>\|:.]) 0:Error
add-highlighter shared/hemlock/code/unaligned_continue_punctuation regex ^(\ \ \ \ )*([\x7D\]),!'\-+*/%@$<=>\|:.]) 0:Error
add-highlighter shared/hemlock/code/unaligned_continue_caret regex ^(\ \ \ \ )*([\^](?![&A-Za-z_])) 0:Error
add-highlighter shared/hemlock/code/trailing regex (\ )+$ 0:ExcessWhitespace
add-highlighter shared/hemlock/code/interior_multispace regex (?<=\S)(\ ){2,}(?=\S) 0:ExcessWhitespace
Expand Down
2 changes: 1 addition & 1 deletion ide/kakoune/hocc.kak
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ add-highlighter shared/hocc/code/uident regex \b[_]*[a-z][A-Za-z0-9_']*\b 0:Defa
add-highlighter shared/hocc/code/tab regex \t 0:Error
add-highlighter shared/hocc/code/unaligned regex ^(\ \ )*\ (?![\ ]) 0:Error
add-highlighter shared/hocc/code/unaligned_continue_keyword regex ^(\ \ \ \ )*(and|also|as|else|external|of|or|then|when|with)\b 0:Error
add-highlighter shared/hocc/code/unaligned_continue_punctuation regex ^(\ \ \ \ )*([\x7D\]),!'\\\-+*/%@$<=>\|:.]) 0:Error
add-highlighter shared/hocc/code/unaligned_continue_punctuation regex ^(\ \ \ \ )*([\x7D\]),!'\-+*/%@$<=>\|:.]) 0:Error
add-highlighter shared/hocc/code/unaligned_continue_caret regex ^(\ \ \ \ )*([\^](?![&A-Za-z_])) 0:Error
add-highlighter shared/hocc/code/trailing regex (\ )+$ 0:ExcessWhitespace
add-highlighter shared/hocc/code/interior_multispace regex (?<=\S)(\ ){2,}(?=\S) 0:ExcessWhitespace
Expand Down
8 changes: 0 additions & 8 deletions src/Basis/Bool.hmi
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ to_uns: t -> uns
not: t -> t
[@@doc "`not t` returns the logical negation of `t`."]

[@@@doc "The && and || operators are magically short-circuiting. If we define equivalent operators
they lose the short-circuiting magic.

```hemlock
( && ): t -> t -> t
( || ): t -> t -> t
```"]

fmt >e: ?pad:codepoint -> ?just:Fmt.just -> ?width:uns -> t -> Fmt.Formatter e >e-> Fmt.Formatter e
[@@doc "`fmt ~pad ~just ~width s formatter` calls `formatter.fmt` on the result of `to_string ~pad
~just ~width s`."]

0 comments on commit 2bada21

Please sign in to comment.