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

refine Callable attributes as if they were functions and vice versa #1472

Open
ghost opened this issue Aug 14, 2016 · 2 comments
Open

refine Callable attributes as if they were functions and vice versa #1472

ghost opened this issue Aug 14, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 14, 2016

It’d be nice to be able to refine Callable attributes as if they were functions and vice versa. Things that I’d like to see working:

abstract class Foo()
{
    shared formal String(String) surround;
}

class Bar()
extends Foo()
{
    shared actual String surround(String str) => "\{RIGHT DOUBLE QUOTATION MARK}``str``\{LEFT DOUBLE QUOTATION MARK}";
}
abstract class Foo()
{
    shared formal String id(String str);
}

class Bar()
extends Foo()
{
    id = identity<String>;
    // or
    // shared formal String id = identity<String>;
}
abstract class Foo<T>()
{
    shared formal T member;
}

class Bar()
extends Foo<String(String)>()
{
    shared formal String member(String str) => "\"``string``\"";
}

A little harder to support:

abstract class Foo()
{
    shared formal String member(String str);
}

class Bar()
{
    shared formal String(String) member
    {
        if(random())
        {
            retrun(identity<String>);
        }
        else
        {
            return(function(String str) => str + "!!!");
        }
    }
}
@ghost
Copy link
Author

ghost commented Aug 14, 2016

Oops, wrong repo, I’ll migrate this issue to the new repo. Derp.

@lucaswerkmeister
Copy link
Member

Shortcut refinement supports both directions already:

abstract class Foo()
{
    shared formal String(String) surround;
}

class Bar()
extends Foo()
{
    surround(String str) => "\{RIGHT DOUBLE QUOTATION MARK}``str``\{LEFT DOUBLE QUOTATION MARK}";
}

try online

abstract class Foo()
{
    shared formal String id(String str);
}

class Bar()
extends Foo()
{
    id = identity<String>;
}

try online

abstract class Foo<out T>()
{
    shared formal T member;
}

class Bar()
extends Foo<String(String)>()
{
    member(String str) => "\"``string``\"";
}

try online

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