Conflict between function and template with the same name

2014-06-29 Thread Uranuz via Digitalmars-d-learn
I have a question about this example code; import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum //string getByName = getByName(name); } void main() { writeln(getByName!(name)); } This produces

Re: import except one?

2014-06-29 Thread Kapps via Digitalmars-d-learn
A bit late, but you should also be able to do: import scriptlike; alias Config = std.process.Config;

Re: httpS post fail at tango

2014-06-29 Thread Kapps via Digitalmars-d-learn
On Thursday, 26 June 2014 at 17:07:30 UTC, JJDuck wrote: On Thursday, 26 June 2014 at 16:33:57 UTC, JJDuck wrote: I tried to use phobos , but there is no such function exists for posting to https too With Phobos, you can use http://dlang.org/phobos/std_net_curl.html#post. Depending on

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-06-29 06:47, Jeremy Sorensen wrote: I found an example of boilerplate code for Win32 programming in D here: http://wiki.dlang.org/D_for_Win32 I have some questions. 1. It appears that the call to myWinMain from WinMain is to ensure that any exception or error is caught. At first glance

Re: Conflict between function and template with the same name

2014-06-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:16:10 UTC, Uranuz wrote: Is there any reason why function and template conflict. They using different syntax to *call*. For template we have *!* but for function we don't have it. So why compiler is not able to see the difference? I suspect this is by design.

Re: Conflict between function and template with the same name

2014-06-29 Thread Uranuz via Digitalmars-d-learn
import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum getByName = .getByName(name); } void main() { writeln(getByName!(name)); } Thanks a lot! Very interesting. Do you see any reasoning why this happens?

Re: Conflict between function and template with the same name

2014-06-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 June 2014 at 08:52:36 UTC, Uranuz wrote: import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum getByName = .getByName(name); } void main() { writeln(getByName!(name)); } Thanks a lot! Very interesting.

Re: Conflict between function and template with the same name

2014-06-29 Thread Timon Gehr via Digitalmars-d-learn
On 06/29/2014 11:31 AM, Rene Zwanenburg wrote: On Sunday, 29 June 2014 at 08:52:36 UTC, Uranuz wrote: import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum getByName = .getByName(name); } void main() { writeln(getByName!(name));

How to forward format specifiers ?

2014-06-29 Thread Element 126 via Digitalmars-d-learn
I am trying to define custom format specifiers (as described here [1]) for the following wrapper struct : import std.stdio; import std.format: formattedWrite, FormatSpec; import std.string: format; struct wrapper(T) { private T val; public this(T newVal) pure { val = newVal;

Re: How to forward format specifiers ?

2014-06-29 Thread Ali Çehreli via Digitalmars-d-learn
On 06/29/2014 04:55 AM, Element 126 wrote: I've certainly missed something formatValue passes your tests: import std.stdio; import std.format: formattedWrite, FormatSpec, formatValue; import std.string: format; struct wrapper(T) { private T val; public this(T newVal) pure { val =

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Jeremy Sorensen via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:51:50 UTC, Jacob Carlborg wrote: You don't need to use WinMain. You can use a plain D main function and add the -L/SUBSYSTEM:WINDOWS:4.0 link flag to suppress the console. There are API's to get access to the arguments passed to WinMain, if necessary. OK so I

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Trass3r via Digitalmars-d-learn
The only question I have is what happens when you use SUBSYSTEM:WINDOWS:4.0 (Which I understand means XP or higher) and the program runs on something older? WinXP is dead :)

Re: How to forward format specifiers ?

2014-06-29 Thread Element 126 via Digitalmars-d-learn
On 06/29/2014 04:22 PM, Ali Çehreli wrote: On 06/29/2014 04:55 AM, Element 126 wrote: I've certainly missed something formatValue passes your tests: import std.stdio; import std.format: formattedWrite, FormatSpec, formatValue; import std.string: format; struct wrapper(T) { private T

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-06-29 17:06, Jeremy Sorensen wrote: The only question I have is what happens when you use SUBSYSTEM:WINDOWS:4.0 (Which I understand means XP or higher) and the program runs on something older? Will you get an error message or just silent failure? Actually, I don't know. You could try

Bizarre compile error in GtkD

2014-06-29 Thread Evan Davis via Digitalmars-d-learn
Hello, I have a compile error when trying to use GtkD 2.3.3. When I try to create a FileChooseDialog, I call new FileChooserDialog(Save File, editor.drawingArea.getParent().getParentWindow(), FileChooserAction.SAVE, [OK,

Re: What is best way to communicate between computer in local network ?

2014-06-29 Thread ponce via Digitalmars-d-learn
On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: Hi, I have a linux network and i would like to know if they are a D library to communicate between computer efficiently. I do not know if that is better to use websocket and if they exists into dlang: -

Re: How to forward format specifiers ?

2014-06-29 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jun 29, 2014 at 06:08:24PM +0200, Element 126 via Digitalmars-d-learn wrote: [...] I have used formattedWrite for months without noticing formatValue, even though it was on the wiki. Maybe I should add an example to the documentation of std.format. formatValue is present but without

Redirect to different overloads at compile time?

2014-06-29 Thread David Bregman via Digitalmars-d-learn
Suppose I have a C library which implements a function for several types. C doesn't have overloading, so their names will be distinct. extern(C): double foo_double(double); float foo_float(float); Now I want to build a D wrapper, and merge them into a single function with overloading: T

Re: Redirect to different overloads at compile time?

2014-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sun, 29 Jun 2014 22:24:09 -0400, David Bregman d...@sfu.ca wrote: Suppose I have a C library which implements a function for several types. C doesn't have overloading, so their names will be distinct. extern(C): double foo_double(double); float foo_float(float); Now I want to build a D

Re: import except one?

2014-06-29 Thread Puming via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:28:12 UTC, Kapps wrote: A bit late, but you should also be able to do: import scriptlike; alias Config = std.process.Config; Thanks, so an alias or an additional single symbol import will shadow the earlier imported symbol. That's fine for me :-)

Re: Redirect to different overloads at compile time?

2014-06-29 Thread Kenji Hara via Digitalmars-d-learn
On Monday, 30 June 2014 at 02:24:10 UTC, David Bregman wrote: Suppose I have a C library which implements a function for several types. C doesn't have overloading, so their names will be distinct. extern(C): double foo_double(double); float foo_float(float); Now I want to build a D wrapper,

Re: Redirect to different overloads at compile time?

2014-06-29 Thread David Bregman via Digitalmars-d-learn
On Monday, 30 June 2014 at 04:50:05 UTC, Kenji Hara wrote: In D, you can merge arbitrary overloads by using alias declaration. Oh wow, you are right. That's a nice feature! I guess I simplified too much for the sake of making the post, the functions I would actually like to merge are

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Jeremy Sorensen via Digitalmars-d-learn
On Sunday, 29 June 2014 at 18:16:05 UTC, Jacob Carlborg wrote: On 2014-06-29 17:06, Jeremy Sorensen wrote: The only question I have is what happens when you use SUBSYSTEM:WINDOWS:4.0 (Which I understand means XP or higher) and the program runs on something older? Will you get an error

Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Jeremy Sorensen via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:51:50 UTC, Jacob Carlborg wrote: You don't need to use WinMain. You can use a plain D main function and add the -L/SUBSYSTEM:WINDOWS:4.0 link flag to suppress the console. There are API's to get access to the arguments passed to WinMain, if necessary. Thanks