Re: Need runtime reflection?

2012-07-17 Thread Paulo Pinto
On Tuesday, 17 July 2012 at 15:08:18 UTC, David Piepgrass wrote: I want to imitate golang's interface in D, to study D's template. I wrote some code: https://gist.github.com/3123593 Now we can write code like golang: -- interface IFoo { void foo(int a, string b, float c); } struct Foo {

Re: K&R-style variadic functions

2012-07-17 Thread Paulo Pinto
On Tuesday, 17 July 2012 at 18:37:54 UTC, H. S. Teoh wrote: I guess you predate me. ;-) When I started learning C, it was already in the ANSI syntax, though there were enough K&R style code floating around that I've at least _seen_ K&R syntax. I'm guessing nowadays most people don't even know

Re: Need runtime reflection?

2012-07-17 Thread lijie
On Tue, Jul 17, 2012 at 11:08 PM, David Piepgrass wrote: > > I, too, was enamored with Go Interfaces and implemented them for .NET: > > http://www.codeproject.com/**Articles/87991/Dynamic-** > interfaces-in-any-NET-language

Re: K&R-style variadic functions

2012-07-17 Thread Matt Soucy
Definitely - I live in a very technologically-savvy dorm in college, and when I encountered it for the first time nobody there had any idea what it was. ...we did later find an old book in our library that had it, though. -Matt On 07/17/2012 02:39 PM, H. S. Teoh wrote: On Tue, Jul 17, 2012 at

Re: reference to 'self' inside a function

2012-07-17 Thread Jonathan M Davis
On Wednesday, July 18, 2012 00:03:25 bearophile wrote: > angel: > > I propose to introduce a reference to the current function, > > much like 'this' in a class method. Call it 'self' or > > 'thisFunc', or whatever ... > > Or __func or something. I'm asking for it for years. You could always use _

Re: reference to 'self' inside a function

2012-07-17 Thread Kevin Cox
On Jul 17, 2012 6:50 PM, "Era Scarecrow" wrote: > > On Tuesday, 17 July 2012 at 22:13:13 UTC, Eyyub wrote: >> >> On Tuesday, 17 July 2012 at 16:56:17 UTC, angel wrote: >>> >>> I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFun

Re: reference to 'self' inside a function

2012-07-17 Thread Era Scarecrow
On Tuesday, 17 July 2012 at 22:13:13 UTC, Eyyub wrote: On Tuesday, 17 July 2012 at 16:56:17 UTC, angel wrote: I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... What might this be good for ? For implemen

Re: Octal Literals

2012-07-17 Thread Nick Sabalausky
On Tue, 17 Jul 2012 23:53:47 +0200 "Dave X." wrote: > I'm a fresh college graduate who just got a job as a software > developer, and I have been enthusiastically watching D for a > while now (I program primarily in Java and C). I have some > functional programming experience in Haskell and Sca

Re: reference to 'self' inside a function

2012-07-17 Thread Eyyub
On Tuesday, 17 July 2012 at 16:56:17 UTC, angel wrote: I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... What might this be good for ? For implementing recursion in a lambda function. Writing in function

Re: reference to 'self' inside a function

2012-07-17 Thread angel
Other languages provide other means. In any case, I don't think it would be a problem if D solved a problem other languages failed to resolve properly. As for http://d.puremagic.com/issues/show_bug.cgi?id=7176, this is pretty much orthogonal to the 'self reference'.

Re: reference to 'self' inside a function

2012-07-17 Thread bearophile
angel: I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... Or __func or something. I'm asking for it for years. Bye, bearophile

Octal Literals

2012-07-17 Thread Dave X.
I'm a fresh college graduate who just got a job as a software developer, and I have been enthusiastically watching D for a while now (I program primarily in Java and C). I have some functional programming experience in Haskell and Scala as well. I like using octal numbers, and I've always been

Re: reference to 'self' inside a function

2012-07-17 Thread Timon Gehr
On 07/17/2012 06:56 PM, angel wrote: I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... What might this be good for ? For implementing recursion in a lambda function. Writing in functional style, one create

Re: K&R-style variadic functions

2012-07-17 Thread Lukasz
I was sure that if function is declared with empty () than you can call it with any arguments you imagine, as it is in following examples. = ex. 1 <*> cat main.c void a() { } int main() { a(1, 2, 3); return 0; } <*> gcc -Wall -Wextra -pedantic main.c <*> =

Re: Rust updates

2012-07-17 Thread Timon Gehr
On 07/17/2012 07:25 PM, bearophile wrote: Walter Bright: auto code() { return cast(ushort)42; } works fine. There isn't really a lack here, just some more typing. I just don't see the case coming up hardly at all. I have just found an example (reduced code): import std.typecons; void main(

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 17:13, Regan Heath wrote: Is Clang open source, can we see the code for that function? Perhaps it's a bug.. ANSI C may have made () without "void" obsolete, but no compiler I've ever used has actually enforced that - or perhaps C++ made old-style function definition/declarations o

Re: Rust updates

2012-07-17 Thread SomeDude
On Friday, 13 July 2012 at 14:58:57 UTC, bearophile wrote: A blog post about one of the Rust pointers, the "borrowed" ones: http://smallcultfollowing.com/babysteps/blog/2012/07/10/borrowed-pointer-tutorial/ Bye, bearophile Rust is a much more interesting language than Go. At least they are t

Re: Why is std.algorithm so complicated to use?

2012-07-17 Thread Jonathan M Davis
On Tuesday, July 17, 2012 11:47:07 Christophe Travert wrote: > The compiler could stop displaying at about 10 failed constrains and > claim there are more. It would be best if it could figure out what are > the 10 most interesting constrains, but that may not be easy! That seems like a good idea.

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 17:11, Regan Heath wrote: Ahh, I've been looking at the ANSI C spec and assuming that is what you're basing things off, K&R C was pre-ANSI C and may have different rules. I think you should probably aim to be ANSI C compliant and above, and ignore K&R. This page says otherwise:

Re: K&R-style variadic functions

2012-07-17 Thread H. S. Teoh
On Tue, Jul 17, 2012 at 08:07:08PM +0200, Paulo Pinto wrote: > On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote: [...] > >So all K&R function declarations were () with no parameters. > > > >R > > K&R was more than that. This modern C declaration: int main(int argc, char **argv

Re: reference to 'self' inside a function

2012-07-17 Thread H. S. Teoh
On Tue, Jul 17, 2012 at 01:09:09PM -0400, Kevin Cox wrote: > On Jul 17, 2012 1:00 PM, "angel" wrote: > > > > I propose to introduce a reference to the current function, much > > like 'this' in a class method. Call it 'self' or 'thisFunc', or > > whatever ... > > What might this be good for ? > > F

Re: D versionning

2012-07-17 Thread Iain Buclaw
On 17 July 2012 12:05, Wouter Verhelst wrote: > "Chris NS" writes: > >> +1 for a "2.breaking.bugfix" scheme. I've used this scheme on >> anything serious for years, and know many others who have; so it is >> not only popular but also quite tried and proven. Not for every >> project, of course (

Re: K&R-style variadic functions

2012-07-17 Thread Paulo Pinto
On Tuesday, 17 July 2012 at 15:13:52 UTC, Regan Heath wrote: On Tue, 17 Jul 2012 15:50:27 +0100, Jacob Carlborg wrote: On 2012-07-17 16:37, Regan Heath wrote: All my googling for "old style" "variadic" etc returned the use of va_alist and va_dcl so I can't see where/why Clang would do what

Re: K&R-style variadic functions

2012-07-17 Thread Paulo Pinto
On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote: On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg wrote: On 2012-07-17 16:36, Regan Heath wrote: I believe old-style no parameter function declarations MUST have "void" i.e. int foo(void); That is still the case, regardle

Re: K&R-style variadic functions

2012-07-17 Thread Daniel Murphy
"deadalnix" wrote in message news:ju3uqc$55g$1...@digitalmars.com... > > It is used in testfptr.d from dmd's testsuite. No, that's a D-linkage variadic.

Re: Rust updates

2012-07-17 Thread bearophile
Walter Bright: auto code() { return cast(ushort)42; } works fine. There isn't really a lack here, just some more typing. I just don't see the case coming up hardly at all. I have just found an example (reduced code): import std.typecons; void main() { alias Tuple!(ubyte[]) Tu; a

Re: std.algorithm imporvments

2012-07-17 Thread Jonathan M Davis
On Tuesday, July 17, 2012 10:47:50 Andrei Alexandrescu wrote: > On 7/17/12 4:41 AM, monarch_dodra wrote: > > On Monday, 16 July 2012 at 22:42:47 UTC, Andrei Alexandrescu > > > > wrote: > >> Wow, this is awesome. Did you discover that by inspection or by > >> testing? I think a "malicious input ran

Re: reference to 'self' inside a function

2012-07-17 Thread Kevin Cox
On Jul 17, 2012 1:00 PM, "angel" wrote: > > I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... > What might this be good for ? > For implementing recursion in a lambda function. > Writing in functional style

reference to 'self' inside a function

2012-07-17 Thread angel
I propose to introduce a reference to the current function, much like 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ... What might this be good for ? For implementing recursion in a lambda function. Writing in functional style, one creates many functions, and looking for r

Re: Definition of "OutputRange" insuficient

2012-07-17 Thread monarch_dodra
OutputRange is designed for infinite output ranges, like output files and appender. [snip] Well, "designed" is open for interpretation. Yes, all (most) "ranges defined as output" (files, streams, appenders) are infinite, and don't define empty (or define it as false). But that does not me

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg wrote: On 2012-07-17 16:36, Regan Heath wrote: I believe old-style no parameter function declarations MUST have "void" i.e. int foo(void); That is still the case, regardless of "style"? They cannot read: int foo(); The latter

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 15:50:27 +0100, Jacob Carlborg wrote: On 2012-07-17 16:37, Regan Heath wrote: All my googling for "old style" "variadic" etc returned the use of va_alist and va_dcl so I can't see where/why Clang would do what it's doing. To be accurate it's the libclang function "clang_

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg wrote: On 2012-07-17 16:36, Regan Heath wrote: I believe old-style no parameter function declarations MUST have "void" i.e. int foo(void); That is still the case, regardless of "style"? They cannot read: int foo(); The latter

Re: Need runtime reflection?

2012-07-17 Thread David Piepgrass
I want to imitate golang's interface in D, to study D's template. I wrote some code: https://gist.github.com/3123593 Now we can write code like golang: -- interface IFoo { void foo(int a, string b, float c); } struct Foo { void foo(int a, string b, float c) { writeln("Foo.foo: "

Re: K&R-style variadic functions

2012-07-17 Thread deadalnix
On 17/07/2012 08:56, Jacob Carlborg wrote: To my understanding this is legal C : int foo (); It's a K&R-style variadic functions, while their use is discouraged, they're still legal C. If I, in D, declare a variadic function with C linkage that doesn't take, at least, one regular parameter the

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 16:37, Regan Heath wrote: All my googling for "old style" "variadic" etc returned the use of va_alist and va_dcl so I can't see where/why Clang would do what it's doing. To be accurate it's the libclang function "clang_isFunctionTypeVariadic" that returns true. http://clang.ll

Re: Definition of "OutputRange" insuficient

2012-07-17 Thread Andrei Alexandrescu
On 7/17/12 6:44 AM, monarch_dodra wrote: I was trying to fix a few bugs in algorithm, as well as be more correct in template type specifiers, and I have to say: There is a serious restraint in the definition of an outputRange. The current definition of "isOutputRange" is simply that "an output r

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 16:36, Regan Heath wrote: I believe old-style no parameter function declarations MUST have "void" i.e. int foo(void); That is still the case, regardless of "style"? They cannot read: int foo(); The latter MUST have parameters, we just can't tell what they are. Ta

Re: std.algorithm imporvments

2012-07-17 Thread Andrei Alexandrescu
On 7/17/12 4:41 AM, monarch_dodra wrote: On Monday, 16 July 2012 at 22:42:47 UTC, Andrei Alexandrescu wrote: Wow, this is awesome. Did you discover that by inspection or by testing? I think a "malicious input range" would be a great tool for assessing which algorithms fail on input ranges. Andr

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 15:01:02 +0100, Jacob Carlborg wrote: On 2012-07-17 15:05, Regan Heath wrote: In my specific case I could add "int a" as the first parameter, and all was well. Each case will be different, and it's conceivable there is a C old-style variadic which takes /any/ type of firs

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 15:02:44 +0100, Jacob Carlborg wrote: On 2012-07-17 14:32, Regan Heath wrote: After a bit of googling and a test with my local MSVC9 I think old-style variadics look like this: #include #include void foo(va_alist) va_dcl { va_list p; va_start(p); v

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 15:05, Regan Heath wrote: In my specific case I could add "int a" as the first parameter, and all was well. Each case will be different, and it's conceivable there is a C old-style variadic which takes /any/ type of first parameter, which could be a problem, however the key issue

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 14:32, Regan Heath wrote: After a bit of googling and a test with my local MSVC9 I think old-style variadics look like this: #include #include void foo(va_alist) va_dcl { va_list p; va_start(p); vprintf("%d %d %d\n", p); } void main() { foo(1, 2, 3);

Re: Exquisite code samples

2012-07-17 Thread renoX
On Tuesday, 10 July 2012 at 09:24:42 UTC, Don Clugston wrote: On 10/07/12 09:49, renoX wrote: On Monday, 9 July 2012 at 11:40:37 UTC, Gor Gyolchanyan wrote: [cut] You're right. This is a bit advanced code sample, which uses templates,template constraints, contract programming among syntax adv

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 13:32:08 +0100, Regan Heath wrote: On Tue, 17 Jul 2012 12:43:46 +0100, Jacob Carlborg wrote: On 2012-07-17 09:06, Mehrdad wrote: My eyes!! They're bleeding!! First I wanted to know if my interpretation is correct and then I was trying to figure out how my tool sho

Re: Definition of "OutputRange" insuficient

2012-07-17 Thread Christophe Travert
"monarch_dodra" , dans le message (digitalmars.D:172586), a écrit : > I was trying to fix a few bugs in algorithm, as well as be more > correct in template type specifiers, and I have to say: There is > a serious restraint in the definition of an outputRange. > > The current definition of "isOut

Re: K&R-style variadic functions

2012-07-17 Thread Regan Heath
On Tue, 17 Jul 2012 12:43:46 +0100, Jacob Carlborg wrote: On 2012-07-17 09:06, Mehrdad wrote: My eyes!! They're bleeding!! First I wanted to know if my interpretation is correct and then I was trying to figure out how my tool should behave if it encounters a function like this. After

Re: D versionning

2012-07-17 Thread deadalnix
On 17/07/2012 06:37, RivenTheMage wrote: On Monday, 16 July 2012 at 22:14:03 UTC, Jonathan M Davis wrote: Going to v3 would mean incrementing the 2. We have _no_ intention of doing that for years to come. Small steps are perfect for many projects, but - in my opinion - not for a programming l

Re: Why is std.algorithm so complicated to use?

2012-07-17 Thread Christophe Travert
Jonathan M Davis , dans le message (digitalmars.D:172564), a écrit : > They're likely to contain a lot of stuff negation of other template > constraints. For instance, > > auto func(R)(R range) > if(isForwardRange!R && !isBidirectionalRange!R) > {} > > auto func(R)(R range) > if(isBidire

Re: K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
On 2012-07-17 09:06, Mehrdad wrote: My eyes!! They're bleeding!! First I wanted to know if my interpretation is correct and then I was trying to figure out how my tool should behave if it encounters a function like this. -- /Jacob Carlborg

Re: Why doesn't to!MyEnumType(42) work

2012-07-17 Thread Christophe Travert
"Era Scarecrow" , dans le message (digitalmars.D:172568), a écrit : > On Monday, 16 July 2012 at 21:59:17 UTC, Tommi wrote: >> On Monday, 16 July 2012 at 20:22:12 UTC, Era Scarecrow wrote: >>> MyEnumType y = cast(MyEnumType) 42; //Error: wtf is 42 anyways? >> >> Like the previous fellow said, it's

Re: D versionning

2012-07-17 Thread Wouter Verhelst
"Chris NS" writes: > +1 for a "2.breaking.bugfix" scheme. I've used this scheme on > anything serious for years, and know many others who have; so it is > not only popular but also quite tried and proven. Not for every > project, of course (although I don't understand why the Linux kernel > tea

Re: Progress on std.container

2012-07-17 Thread Tobias Pankrath
I'm the bottleneck for that. My list of actual work (aside from my duties as phobos/druntime/tools/dlang.org curator) is: 1. Put std.benchmark through the review process 2. Define allocators 3. Integrate allocators with std.container If you have fixes for std.container that are faraway fr

Definition of "OutputRange" insuficient

2012-07-17 Thread monarch_dodra
I was trying to fix a few bugs in algorithm, as well as be more correct in template type specifiers, and I have to say: There is a serious restraint in the definition of an outputRange. The current definition of "isOutputRange" is simply that "an output range is defined functionally as a range

Re: K&R-style variadic functions

2012-07-17 Thread Paulo Pinto
On Tuesday, 17 July 2012 at 07:06:38 UTC, Mehrdad wrote: On Tuesday, 17 July 2012 at 06:56:17 UTC, Jacob Carlborg wrote: To my understanding this is legal C : int foo (); It's a K&R-style variadic functions, while their use is discouraged, they're still legal C. My eyes!! They're bleeding

Re: std.algorithm imporvments

2012-07-17 Thread monarch_dodra
On Monday, 16 July 2012 at 22:42:47 UTC, Andrei Alexandrescu wrote: Wow, this is awesome. Did you discover that by inspection or by testing? I think a "malicious input range" would be a great tool for assessing which algorithms fail on input ranges. Andrei The first I discovered testing with

Re: K&R-style variadic functions

2012-07-17 Thread Mehrdad
On Tuesday, 17 July 2012 at 06:56:17 UTC, Jacob Carlborg wrote: To my understanding this is legal C : int foo (); It's a K&R-style variadic functions, while their use is discouraged, they're still legal C. My eyes!! They're bleeding!!

K&R-style variadic functions

2012-07-17 Thread Jacob Carlborg
To my understanding this is legal C : int foo (); It's a K&R-style variadic functions, while their use is discouraged, they're still legal C. If I, in D, declare a variadic function with C linkage that doesn't take, at least, one regular parameter the compiler will complain. extern (C) int