Re: How to do alias to a C struct member?

2019-04-22 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 22 April 2019 at 15:50:11 UTC, dangbinghoo wrote: On Monday, 22 April 2019 at 13:10:45 UTC, Adam D. Ruppe wrote: On Monday, 22 April 2019 at 11:04:49 UTC, dangbinghoo wrote: alias ifr_ifrn.ifrn_nameifr_name; /* interface name */ So, how to do alias for a C

Re: Question regarding readf

2019-04-22 Thread Ali Çehreli via Digitalmars-d-learn
On 04/22/2019 03:29 PM, Andre Pany wrote: > I wonder wheter std.stdio is missing a readfln function. Which executes > readln, strips the #10#13 characters and then executes formattedRead. > Does that make sense to you? Makes sense but what we are missing is standard streaming (like C++'s

Re: Question regarding readf

2019-04-22 Thread Andre Pany via Digitalmars-d-learn
On Monday, 22 April 2019 at 22:08:33 UTC, Ali Çehreli wrote: On 04/22/2019 01:45 PM, Andre Pany wrote: Hi, following the example from http://ddili.org/ders/d.en/input.html, I try to read a value from console on windows (powershell and dos console). The code from the example does not work,

Re: Question regarding readf

2019-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 April 2019 at 20:45:54 UTC, Andre Pany wrote: The code from the example does not work, writeln is never executed. For "%s" with a string argument, it reads ALL of stdin into that string. This means you need to send an end-of-file indicator to the program. ctrl+z on Windows does

Re: alias fails to compile

2019-04-22 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 22 April 2019 at 19:57:11 UTC, aliak wrote: On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = B.bb; } void main() { A a = A(); // a.b.bb = 4; // works

Re: Question regarding readf

2019-04-22 Thread Ali Çehreli via Digitalmars-d-learn
On 04/22/2019 01:45 PM, Andre Pany wrote: Hi, following the example from http://ddili.org/ders/d.en/input.html, I try to read a value from console on windows (powershell and dos console). The code from the example does not work, writeln is never executed. import std; void main() {

Re: Ordering of UDAs

2019-04-22 Thread Emmanuelle via Digitalmars-d-learn
On Monday, 22 April 2019 at 19:32:27 UTC, Adam D. Ruppe wrote: On Monday, 22 April 2019 at 19:02:57 UTC, Emmanuelle wrote: Hello! Does `__traits(getAttributes, ...)` return UDAs in the order they were declared in the source code, or is it unspecified? I think that is defined:

Question regarding readf

2019-04-22 Thread Andre Pany via Digitalmars-d-learn
Hi, following the example from http://ddili.org/ders/d.en/input.html, I try to read a value from console on windows (powershell and dos console). The code from the example does not work, writeln is never executed. import std; void main() { while(true) {

Re: alias fails to compile

2019-04-22 Thread aliak via Digitalmars-d-learn
On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = B.bb; } void main() { A a = A(); // a.b.bb = 4; // works a.aa = 4; // fails } https://run.dlang.io/is/kXaVy2

Re: Ordering of UDAs

2019-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 April 2019 at 19:02:57 UTC, Emmanuelle wrote: Hello! Does `__traits(getAttributes, ...)` return UDAs in the order they were declared in the source code, or is it unspecified? I think that is defined: https://dlang.org/spec/attribute.html#uda "If there are multiple UDAs in

Ordering of UDAs

2019-04-22 Thread Emmanuelle via Digitalmars-d-learn
Hello! Does `__traits(getAttributes, ...)` return UDAs in the order they were declared in the source code, or is it unspecified?

Does D have a tool like pySnooper?

2019-04-22 Thread Taylor Hillegeist via Digitalmars-d-learn
Saw this tool and thought D could probably do something like this pretty easily. Is there such a tool out there already? https://github.com/cool-RR/pysnooper Or would this not be easy at all with D?

Re: How to do alias to a C struct member?

2019-04-22 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 22 April 2019 at 15:45:52 UTC, Arun Chandrasekaran wrote: On Monday, 22 April 2019 at 11:04:49 UTC, dangbinghoo wrote: hi all, as now we don't have the net/if.h binding, I need to do struct ifreq binding myself, here's my code: [...] Looks like we both were working on the same

Re: How to do alias to a C struct member?

2019-04-22 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 22 April 2019 at 13:10:45 UTC, Adam D. Ruppe wrote: On Monday, 22 April 2019 at 11:04:49 UTC, dangbinghoo wrote: alias ifr_ifrn.ifrn_nameifr_name; /* interface name */ So, how to do alias for a C struct member? D doesn't support this kind of alias. There's two

Re: How to do alias to a C struct member?

2019-04-22 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 22 April 2019 at 11:04:49 UTC, dangbinghoo wrote: hi all, as now we don't have the net/if.h binding, I need to do struct ifreq binding myself, here's my code: [...] Looks like we both were working on the same thing, few hours apart.

Re: alias fails to compile

2019-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
see this other thread for possible solutions too https://forum.dlang.org/post/anasidaotexgfkyiq...@forum.dlang.org

Re: alias fails to compile

2019-04-22 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 22 April 2019 at 14:07:11 UTC, Alex wrote: On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = b.bb; } void main() { A a = A(); // a.b.bb = 4; // works

Re: Loading of wasm function fails

2019-04-22 Thread dokutoku via Digitalmars-d-learn
On Monday, 22 April 2019 at 13:05:03 UTC, Adam D. Ruppe wrote: On Monday, 22 April 2019 at 10:36:23 UTC, dokutoku wrote: How can I solve this problem? I played with this last week, try adding -L--export-dynamic to your ldc command line to build. I mentioned it briefly on my blog last week

Re: alias fails to compile

2019-04-22 Thread Alex via Digitalmars-d-learn
On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = b.bb; } void main() { A a = A(); // a.b.bb = 4; // works a.aa = 4; // fails } https://run.dlang.io/is/kXaVy2

Re: How to do alias to a C struct member?

2019-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 April 2019 at 11:04:49 UTC, dangbinghoo wrote: alias ifr_ifrn.ifrn_nameifr_name; /* interface name */ So, how to do alias for a C struct member? D doesn't support this kind of alias. There's two options: 1) just write the full name in the code. ifreq ifr;

Re: Loading of wasm function fails

2019-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 April 2019 at 10:36:23 UTC, dokutoku wrote: How can I solve this problem? I played with this last week, try adding -L--export-dynamic to your ldc command line to build. I mentioned it briefly on my blog last week

How to do alias to a C struct member?

2019-04-22 Thread dangbinghoo via Digitalmars-d-learn
hi all, as now we don't have the net/if.h binding, I need to do struct ifreq binding myself, here's my code: struct ifreq { private union ifr_ifrn { byte[IFNAMSIZ] ifrn_name; /* if name, e.g. "en0" */ } private union ifr_ifru {

Loading of wasm function fails

2019-04-22 Thread dokutoku via Digitalmars-d-learn
I try to use wasm with LDC, but I can not load wasm functions with the following message even if I write it the same as the "Generating WebAssembly with LDC" page on wiki TypeError: exports.add is not a function How can I solve this problem?

Re: How to debug long-lived D program memory usage?

2019-04-22 Thread ikod via Digitalmars-d-learn
On Sunday, 21 April 2019 at 21:04:52 UTC, Patrick Schluter wrote: On Thursday, 18 April 2019 at 12:00:10 UTC, ikod wrote: On Wednesday, 17 April 2019 at 16:27:02 UTC, Adam D. Ruppe wrote: D programs are a vital part of my home computer infrastructure. I run some 60 D processes at almost any

Re: alias fails to compile

2019-04-22 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = B.bb; } void main() { A a = A(); // a.b.bb = 4; // works a.aa = 4; // fails } https://run.dlang.io/is/kXaVy2

alias fails to compile

2019-04-22 Thread Arun Chandrasekaran via Digitalmars-d-learn
What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = B.bb; } void main() { A a = A(); // a.b.bb = 4; // works a.aa = 4; // fails } https://run.dlang.io/is/kXaVy2

Re: Anyone have a Vibe.d Diet Template syntax definition for Sublime?

2019-04-22 Thread Andrej Mitrovic via Digitalmars-d-learn
On Monday, 22 April 2019 at 04:12:11 UTC, Andrej Mitrovic wrote: Or perhaps for any other editor so I could adapt it and have syntax highlighting in Sublime when viewing .dt files. In the meantime I found this: https://packagecontrol.io/packages/Pug It seems to work fairly well.