dada-lang / dada

I speak only of myself since I do not wish to convince, I have no right to drag others into my river, I oblige no one to follow me and everybody practices his art in his own way.
https://dada-lang.org
Apache License 2.0
444 stars 28 forks source link

Parse generic parameters #227

Closed Aadamandersson closed 1 year ago

Aadamandersson commented 1 year ago

This implements parsing of generic parameters for types fn foo[T] and permissions fn foo[perm P].

netlify[bot] commented 1 year ago

Deploy Preview for dada-lang ready!

Name Link
Latest commit 0e9f559992a7e158e8894f45ecc19a6b95636659
Latest deploy log https://app.netlify.com/sites/dada-lang/deploys/645d0823f59451000767b089
Deploy Preview https://deploy-preview-227--dada-lang.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

nikomatsakis commented 1 year ago

Nice! I had thought about having the syntax fn foo[type T], the intention being that every declaration of a generic parameter is preceded by its kind -- but I hadn't made up my mind yet.

One of the advantages would be that you can do interesting things with impl blocks:

class Foo[type T]() {
}

impl Foo[type T] {
    fn bar() { ... }
}

impl Foo[String] {
    ...
}

I'm not sure if this is the direction Dada should go -- both in terms of the type keyword but also having impl blocks to begin with! -- but I'd say it's worth giving it a try.