Re: Problem with using readln.

2017-04-29 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:20:20 UTC, JV wrote: On Sunday, 30 April 2017 at 03:18:04 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: btw i forgot to add () at readln while editing the post That's not necessary, it doesn't change anything. But readln without

alloca without runtime?

2017-04-29 Thread 岩倉 澪 via Digitalmars-d-learn
I've been playing around with using D with no runtime on Linux, but recently I was thinking it would be nice to have an alloca implementation. I was thinking I could just bump the stack pointer (with alignment considerations) but from what I understand compilers sometimes generate code that

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:18:39 UTC, JV wrote: On Sunday, 30 April 2017 at 03:13:14 UTC, JV wrote: On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: int func; writeln("\t\tEnter Selection : "); readln(func);

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:20:20 UTC, JV wrote: On Sunday, 30 April 2017 at 03:18:04 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: okay?? but how do i return an int? tried using what i found in the internet like using std.conv; to use toInt() but still

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:18:04 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: btw i forgot to add () at readln while editing the post That's not necessary, it doesn't change anything. But readln without arguments returns a string, not an int. okay?? but

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:13:14 UTC, JV wrote: On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: Hello i'm kinda new to D language and i wanted to make a simple program but somehow my input does no go to my if statements and just continues to ask for the user to input.Kindly help me

Re: Problem with using readln.

2017-04-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: btw i forgot to add () at readln while editing the post That's not necessary, it doesn't change anything. But readln without arguments returns a string, not an int.

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: Hello i'm kinda new to D language and i wanted to make a simple program but somehow my input does no go to my if statements and just continues to ask for the user to input.Kindly help me btw here is my sample code int func;

Re: Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:04:49 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: int func; writeln("\t\tEnter Selection : "); func = readln; writeln(func); That shouldn't even compile... are you sure that's your actual code, and that it is

Re: Problem with using readln.

2017-04-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: int func; writeln("\t\tEnter Selection : "); func = readln; writeln(func); That shouldn't even compile... are you sure that's your actual code, and that it is actually building successfully?

Re: alias can't find symbol or can't use symbol

2017-04-29 Thread bauss via Digitalmars-d-learn
On Sunday, 30 April 2017 at 00:17:37 UTC, Carl Sturtivant wrote: Consider the following. struct member { int n; } struct outer { member x; alias x this; alias n2 = n; } This does not compile: alias n2 = n; Error: undefined identifier 'n' On the other hand if change that into

Problem with using readln.

2017-04-29 Thread JV via Digitalmars-d-learn
Hello i'm kinda new to D language and i wanted to make a simple program but somehow my input does no go to my if statements and just continues to ask for the user to input.Kindly help me btw here is my sample code int func; writeln("\t\tEnter Selection : "); func = readln;

Re: interfacing Cpp - GCC Dual ABI abi_tag in name mangling

2017-04-29 Thread via Digitalmars-d-learn
On Saturday, 29 April 2017 at 19:16:14 UTC, kinke wrote: On Saturday, 29 April 2017 at 18:08:16 UTC, سليمان السهمي (Soulaïman Sahmi) wrote: GCC has this attribute called abi_tag that they put on any function that returns std::string or std::list The usual workaround is compiling the C++

alias can't find symbol or can't use symbol

2017-04-29 Thread Carl Sturtivant via Digitalmars-d-learn
Consider the following. struct member { int n; } struct outer { member x; alias x this; alias n2 = n; } This does not compile: alias n2 = n; Error: undefined identifier 'n' On the other hand if change that into alias n2 = x.n; then it does compile. void main() { outer

Re: User input; quick question.

2017-04-29 Thread fred via Digitalmars-d-learn
On Saturday, 29 April 2017 at 21:18:27 UTC, cym13 wrote: On Saturday, 29 April 2017 at 21:09:13 UTC, fred wrote: import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str);

Re: User input; quick question.

2017-04-29 Thread cym13 via Digitalmars-d-learn
On Saturday, 29 April 2017 at 21:09:13 UTC, fred wrote: import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str); However, the prompt appears after I enter the input; any

User input; quick question.

2017-04-29 Thread fred via Digitalmars-d-learn
import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str); However, the prompt appears after I enter the input; any reason why? I've trawled the internet for a good hour,

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread kinke via Digitalmars-d-learn
On Saturday, 29 April 2017 at 18:54:36 UTC, سليمان السهمي (Soulaïman Sahmi) wrote: But still, this needs to be fixed, copy pasting the name mangling is in my opinion just a hack for your specific cpp compiler on your specific platform. It can't be fixed on the D side as the Visual C++

Re: interfacing Cpp - GCC Dual ABI abi_tag in name mangling

2017-04-29 Thread kinke via Digitalmars-d-learn
On Saturday, 29 April 2017 at 18:08:16 UTC, سليمان السهمي (Soulaïman Sahmi) wrote: GCC has this attribute called abi_tag that they put on any function that returns std::string or std::list The usual workaround is compiling the C++ source with _GLIBCXX_USE_CXX11_ABI=0 for gcc >= 5.

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread via Digitalmars-d-learn
On Saturday, 29 April 2017 at 08:08:27 UTC, ParticlePeter wrote: On Saturday, 29 April 2017 at 00:31:32 UTC, Nicholas Wilson wrote: If you are having problems with the linker with Ali's you can do ``` extern(C++) bool cppFunc( float[3] color ); // correct signature, but causes compiler

interfacing Cpp - GCC Dual ABI abi_tag in name mangling

2017-04-29 Thread via Digitalmars-d-learn
GCC has this attribute called abi_tag that they put on any function that returns std::string or std::list, for the rational behind that read here:https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html . the special thing with this attribute is that it adds something to the name

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 10:17:47 UTC, Atila Neves wrote: On Saturday, 29 April 2017 at 06:22:03 UTC, ParticlePeter wrote: On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote: On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote: [...] The worst part about that is mangling

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread Atila Neves via Digitalmars-d-learn
On Saturday, 29 April 2017 at 06:22:03 UTC, ParticlePeter wrote: On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote: On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote: [...] The worst part about that is mangling aside, the two declarations are identical to the compiler.

Re: problem with std.variant rounding

2017-04-29 Thread via Digitalmars-d-learn
On Friday, 28 April 2017 at 18:08:38 UTC, H. S. Teoh wrote: On Fri, Apr 28, 2017 at 04:42:28PM +, via Digitalmars-d-learn wrote: [...] writefln(text("%.", i, "f"), x); [...] There's no need to use text() here: writefln("%.*f", i, x); does what you want. T Thanks, I

Re: get parameters of a function

2017-04-29 Thread Alex via Digitalmars-d-learn
On Saturday, 29 April 2017 at 08:15:06 UTC, Stanislav Blinov wrote: Ah, that calls for something like a isCallableWith template. Pay extra care to how you pass parameters in that variadic opCall template though. Doing it like in the code above will pass everything by value, even though the

Re: get parameters of a function

2017-04-29 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 29 April 2017 at 06:18:34 UTC, Alex wrote: The problem is another one: say I have something like this: import std.traits; struct A(alias T) if(isCallable!T) { auto opCall(U...)(U args) if(is(Parameters!T == U)) //if(__traits(compiles, T(args))) {

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 00:31:32 UTC, Nicholas Wilson wrote: If you are having problems with the linker with Ali's you can do ``` extern(C++) bool cppFunc( float[3] color ); // correct signature, but causes compiler error pragma(mangle, cppFunc.mangleof) float cppFunc(float * color);

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote: On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote: On Friday, 28 April 2017 at 18:07:49 UTC, ParticlePeter wrote: Interesting, your example corresponds to my third case, the linker error. I am on Window, building an x64 App,

Re: get parameters of a function

2017-04-29 Thread Alex via Digitalmars-d-learn
On Saturday, 29 April 2017 at 05:58:35 UTC, Stanislav Blinov wrote: On Friday, 28 April 2017 at 20:43:50 UTC, Alex wrote: void main() { foreach(o1; __traits(getOverloads, S1, "opCall")) { alias P1 = Parameters!o1; foreach(o2; __traits(getOverloads, S2, "opCall"))

Re: get parameters of a function

2017-04-29 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 28 April 2017 at 20:43:50 UTC, Alex wrote: Hi all, I have a question about the Parameters trait from https://dlang.org/phobos/std_traits.html#Parameters The following code does not compile. Why? Is it mainly assumed to use it with functions without overloads? Rather, it is to be