digitalmars.D.learn - function and variable
- Fyodor Ustinov (17/17) Feb 09 2015 Hi!
- Rikki Cattermole (4/20) Feb 09 2015 That's a bug. It should be using the function pointer.
- Fyodor Ustinov (6/10) Feb 09 2015 Moreover. If the function is not defined (only pointer), I get
- Vlad Levenfeld (4/8) Feb 09 2015 I thought that's how UFCS was explicitly designed? Global symbols
- Fyodor Ustinov (6/15) Feb 09 2015 IMHO even if "it is not a bug, it is a feature" - it should not
- Vlad Levenfeld (3/7) Feb 09 2015 Agreed, should be a warning at least.
Hi! I think this code should not be compiled without any warning: import std.stdio; void f(int a) { writeln("it's a function! : ", a); } void main() { auto f = function (int a) {writeln("It's a variable! : ", a);}; 5.f(); f(5); } Output: it's a function! : 5 It's a variable! : 5 WBR, Fyodor.
Feb 09 2015
On 10/02/2015 4:28 p.m., Fyodor Ustinov wrote:Hi! I think this code should not be compiled without any warning: import std.stdio; void f(int a) { writeln("it's a function! : ", a); } void main() { auto f = function (int a) {writeln("It's a variable! : ", a);}; 5.f(); f(5); } Output: it's a function! : 5 It's a variable! : 5 WBR, Fyodor.That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161
Feb 09 2015
On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote:That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161Moreover. If the function is not defined (only pointer), I get this error: aa.d(5): Error: no property 'f' for type 'int' when try use 5.f();
Feb 09 2015
On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote:That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161I thought that's how UFCS was explicitly designed? Global symbols only, yes?
Feb 09 2015
On Tuesday, 10 February 2015 at 04:11:43 UTC, Vlad Levenfeld wrote:On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote:IMHO even if "it is not a bug, it is a feature" - it should not be compiled without notice. WBR, Fyodor.That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161I thought that's how UFCS was explicitly designed? Global symbols only, yes?
Feb 09 2015
On Tuesday, 10 February 2015 at 04:20:27 UTC, Fyodor Ustinov wrote:IMHO even if "it is not a bug, it is a feature" - it should not be compiled without notice. WBR, Fyodor.Agreed, should be a warning at least.
Feb 09 2015