Thread overview
[Issue 3943] New: "in" function argument is redundant
Mar 13, 2010
Mike Parker
Dec 20, 2012
Andrej Mitrovic
March 12, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3943

           Summary: "in" function argument is redundant
           Product: D
           Version: 2.041
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-03-12 14:47:11 PST ---
This program seems to show that "in" function arguments are the same as "const", and "immutable in" are immutable:


import std.stdio: writeln;
void foo1(const int x) {
    writeln(typeid(typeof(x))); // const(int)
}
void foo2(in int x) {
    writeln(typeid(typeof(x))); // const(int)
}
void foo3(immutable in int x) {
    writeln(typeid(typeof(x))); // immutable(int)
}
void main() {
    foo1(1);
    foo2(1);
    foo3(1);
}


So the "in" attribute for function arguments can be removed from the language, so programmers can use "const", "immutable", etc in a more explicit way.

According to Python Zen: "There should be one-- and preferably only one --obvious way to do it."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3943


Mike Parker <aldacron@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldacron@gmail.com


--- Comment #1 from Mike Parker <aldacron@gmail.com> 2010-03-13 00:10:54 PST ---
I strongly object. Currently, 'in' is one of the few constructs remaining that allow compatibility between D1 and D2 without resorting to versioned blocks and mixins. Take this away, and cross-version compatibility becomes even more of a headache than it already is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3943



--- Comment #2 from bearophile_hugs@eml.cc 2010-03-13 04:33:05 PST ---
My opinions on the topic:
- As a Python user I have seen the usefulness of that part of its Zen. It
speeds up coding, speeds up code reading, makes code more uniform among
different programmers, etc.
- When Andrei's book is out, people will learn the D2 language. I like D1 but
it will probably not last many years. I think some years from now D1 will be
unused. Keeping in D2 a redundancy and baggage for a language that will not
last is bad.

So if you don't want to remove that "in" now, to help in the transitory period of code that works in D1 and D2, it can be kept, deprecated, _plus_ it has to always raise an informative deprecation warning, it must be noisy, otherwise new D2 programmers will use it and it will never be possible to remove it from the language. And then it can be removed in one or two years from now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3943


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |INVALID


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-20 15:39:40 PST ---
"in" is equivalent to "const scope" (there might be some related opened bugs about it though), so it's not redundant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------