Skip to content

Conversation

crusso
Copy link
Contributor

@crusso crusso commented Sep 27, 2025

builds on #5517

  • add implicit keyword and grammer production (so a minor breaking change)

  • expands implicit t to a named type. Since implicit is now a keyword, users can't just use identifier implicit as name for a traditional named type (or anything else for that matter).

  • extends pretty printer, parser and various other bits and bobs.

Let's you write and read:

func sort<T>( array : [T], compare : implicit (Nat, Nat) -> Order) {};
: <T>( array : [], compare : implicit (Nat, Nat) -> Order) -> ()

instead of raw syntax and types:

func sort<T>( array : [T], compare : (implicit (Nat, Nat) -> Order)) {};
: <T>( array : [], compare : (implicit : (Nat, Nat) -> Order)) -> ()

(fewer (..) and : )

  • merge with master

  • fix merge (regen tests)

@crusso crusso changed the base branch from master to claudio/implicits September 27, 2025 18:10
@ggreif
Copy link
Contributor

ggreif commented Oct 4, 2025

I'd suggest

func sort<T>( array : [T], compare : implicit (Nat, Nat) -> Order) {};
: <T>( array : [], with compare : (Nat, Nat) -> Order) -> ()
  • spares us from introducing a new keyword
  • (to me at least) it reads naturally "with compare : (Nat, Nat) -> Order from callsite lexical context"
  • the keyword is right at the beginning
  • most programmers will regard implicit as a very exotic word

implicit-import-hint.mo:11.8-11.18: type error [M0230], Cannot determine implicit argument 'compare' of type
(Text, Text) -> Order
Hint: Did you mean to import mo:core/Text?
Hint: Did you mean to import core-stub/src/Text.mo.compare?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A regression?

{chars : () -> {next : () -> ?Char}; size : () -> Nat}
The field compare is not available. Try something else?
Hint: Did you mean to import mo:core/Text?
Hint: Did you mean to import core-stub/src/Text.mo?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A regression?

Copy link
Contributor

github-actions bot commented Oct 4, 2025

Comparing from 69d8fd4 to 1817b1a:
In terms of gas, no changes are observed in 5 tests.
In terms of size, no changes are observed in 5 tests.

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

Successfully merging this pull request may close these issues.

3 participants