www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11880] New: Reserve the keyword "yield"

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880

           Summary: Reserve the keyword "yield"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



I suggest to reserve the keyword "yield" for future usage (just like the
keyword "macro", "cent", "ucent"). This will avoid backward compatibility
problems with D code that uses variable names "yield" today.

See Issue 5660 for info on "yield".


Today code that uses "yield" should give an explicit error message like this:

test.d(2): Error: yield not implemented


And this should compile:

void main() {
    static assert(!__traits(compiles, { yield(int) foo() { yield 1; }}));
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com



"yield" is already used for function names in core.Thread and core.Fiber.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com



09:42:11 EET ---
As I understand, "yield" doesn't need to be a keyword - it can be implemented
as a language construct. The only limitation is that coroutines need to be
started explicitly (which I think this is a plus as it improves readability).

I suggest closing this as WONTFIX.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880




09:42:54 EET ---
s/language construct/library construct/

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |maxim maxim-fomin.ru
         Resolution|                            |WONTFIX


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880






 As I understand, "yield" doesn't need to be a keyword - it can be implemented
 as a language construct.
Do you have an example usage syntax (and implementation)? And is it going in Phobos? What about Issue 5660 ?
 The only limitation is that coroutines need to be
 started explicitly (which I think this is a plus as it improves readability).
This is the syntax I suggested, I think it's readable. What's the more readable usage syntax that you suggest? yield(int) foo() { yield 1; yield 2; } void main() { import std.stdio, std.algorithm; foo.map!(x => x).writeln; } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11880




14:39:01 EET ---

 Do you have an example usage syntax (and implementation)?
You posted this 5 years ago: http://forum.dlang.org/post/g7uhp6$317g$1 digitalmars.com There are other, similar implementations.
 And is it going in Phobos?
I don't know of any plans for that.
 What about Issue 5660 ?
The same arguments apply there too. I see people posted their own coroutine implementations there as well.
 This is the syntax I suggested, I think it's readable. What's the more readable
 usage syntax that you suggest?
My argument is that the cost of introducing a breaking change in the language is not justified for the sake of syntax sugar. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 11 2014