Re: get element index when using each!(x)

2020-09-16 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 17 September 2020 at 03:16:42 UTC, Paul Backus wrote: On Thursday, 17 September 2020 at 03:14:08 UTC, JG wrote: Perhaps there are other ways, but you can use enumerate. For example --- import std.algorithm; import std.range; import std.stdio; void main() { string s =

get element index when using each!(x)

2020-09-16 Thread dangbinghoo via Digitalmars-d-learn
hi, is there any way to get the index for an element when iteration using each!(x)? I know I can do this using foreach statement, but I prefer using the each template. --- string s = "hello"; foreach(i, c; s) { } -- how can I get to ? Thanks! binghoo dang

Re: Does std.net.curl: download have support for callbacks?

2020-06-17 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 11 June 2020 at 06:13:59 UTC, adnan338 wrote: On Thursday, 11 June 2020 at 06:05:09 UTC, adnan338 wrote: I would like to set a callback for the `download()` function but I do not seem to find a way to add a callback to the procedure. [...] I have also been told that Gtk is not

Re: GUI library for DMD 2.090 or DMD 2.091

2020-04-26 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote: I'm too new to DLang and I have a lot to learn. Probably that's why I have a lot of difficulties. Has anyone tried using a GUI library to the latest DMD 2.090 or DMD 2.091? I plan to use this language for a specific Thermal calculator

Re: Best way to learn 2d games with D?

2020-03-19 Thread dangbinghoo via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer wrote: I want to try and learn how to write 2d games. I'd prefer to do it with D. I've found a ton of tutorials on learning 2d gaming with other languages. Is there a place to look that uses D for learning? Should I just start

Re: Using LDC2 on ARM

2020-03-02 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 2 March 2020 at 17:45:26 UTC, Severin Teona wrote: Hello, I am working on a project that uses a Raspberry Pi (armv7l) and the latest LDC version I found for this architecture is 1.13.0. Can you help me install the latest version(1.20.0)? Also, I'm having problems using the DPP

Re: Is there any writeln like functions without GC?

2019-11-10 Thread dangbinghoo via Digitalmars-d-learn
On Sunday, 3 November 2019 at 05:46:53 UTC, 9il wrote: On Thursday, 31 October 2019 at 03:56:56 UTC, lili wrote: Hi: why writeln need GC? See also Mir's @nogc formatting module https://github.com/libmir/mir-runtime/blob/master/source/mir/format.d hi, is mir right now fully implemented

Re: is the runtime implemented in betterC?

2019-11-09 Thread dangbinghoo via Digitalmars-d-learn
On Saturday, 9 November 2019 at 22:46:16 UTC, kinke wrote: druntime depends on OS, architecture and coupled C runtime - what OS are you going to target? thank you all first! I just made a basic mistake and didn't realized that druntime is just libraries and onlymatter when linking the final

Re: is the runtime implemented in betterC?

2019-11-08 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 8 November 2019 at 13:52:18 UTC, kinke wrote: On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote: hi, I'm not sure what you are trying to achieve; you can easily cross-compile druntime & Phobos with LDC, see https://wiki.dlang.org/Building_LDC_runtime_libraries. hmm,

is the runtime implemented in betterC?

2019-11-08 Thread dangbinghoo via Digitalmars-d-learn
hi, is the runtime d code implemented purely with betterC? i was thinking that what's happening when we building ARM dlang compiler, when the dlang compiler ready in the first, there's no ARM version of the runtime lib and phobos, so, it's likely we are using bare metal D and trying to build

can we use D to programming ESP32?

2019-07-10 Thread dangbinghoo via Digitalmars-d-learn
hi there, Does anyone know what's D's status for ESP32? I just getting started a few days programming with ESP32, and found the official esp-idf SDK even get CPP enabled by default, and this makes the HelloWorld app used 160KB of flash. What I want to talk is that ESP32 might be a powerful

Re: make C is scriptable like D

2019-06-21 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 20 June 2019 at 16:55:01 UTC, Jonathan Marler wrote: On Thursday, 20 June 2019 at 06:20:17 UTC, dangbinghoo wrote: [...] rdmd adds a few different features as well, but the bigger thing it does is cache the results in a global temporary directory. So If you run rdmd on the

Re: is there any micro-service library in D?

2019-06-20 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 11:19:17 UTC, Marco de Wild wrote: On Wednesday, 19 June 2019 at 08:29:15 UTC, dangbinghoo wrote: hi there, Does anyone know the micro-service oriented design library or framework in D? thanks! binghoo dang What do you need from such a library? Some

make C is scriptable like D

2019-06-20 Thread dangbinghoo via Digitalmars-d-learn
hi there, a funny thing: $ cat rgcc #!/bin/sh cf=$@ mycf=__`echo $cf|xargs basename` cat $cf | sed '1d' > ${mycf} gcc ${mycf} -o a.out rm ${mycf} ./a.out $ cat test.c #!/home/user/rgcc #include int main() { printf("hello\n"); }

is there any micro-service library in D?

2019-06-19 Thread dangbinghoo via Digitalmars-d-learn
hi there, Does anyone know the micro-service oriented design library or framework in D? thanks! binghoo dang

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread dangbinghoo via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 10:24:05 UTC, KnightMare wrote: On Tuesday, 11 June 2019 at 08:05:31 UTC, dangbinghoo wrote: I think that D compiler needs -nogc switch to fully disable gc for a project, LDC -nogc? thanks for help. It's a shame that I didn't look in details of the LCD help

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread dangbinghoo via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 12:40:39 UTC, Adam D. Ruppe wrote: On Tuesday, 11 June 2019 at 08:59:01 UTC, dangbinghoo wrote: We need to make sure we use only @nogc API when writing code, not when running the app. That's what the @nogc annotation does, statically forces you to only use other

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread dangbinghoo via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 08:16:31 UTC, Basile B. wrote: On Tuesday, 11 June 2019 at 08:08:14 UTC, Basile B. wrote: you can do this with a druntime switch or by calling GC.disable in your main() the druntime switch is "--DRT-gc=gc:manual". You pass it the compiled program after its own

D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread dangbinghoo via Digitalmars-d-learn
hi there, I think that D compiler needs -nogc switch to fully disable gc for a project, and document of phobos also needs a friendly way to list-out all @nogc API. we already have -betterC, and betterC disabled GC, why we could not have a standalone option for doing this? binghoo

Re: Create object from a library's Class returns Null

2019-05-29 Thread dangbinghoo via Digitalmars-d-learn
change gwlib buildtype to sourceLibrary solves the problem, but it should work for static or shared library.

Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 29 May 2019 at 05:04:54 UTC, dangbinghoo wrote: On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote: Object.factory is pretty unreliable and has few supporters among the developers. I wouldn't suggest relying on it and instead building your own factory functions. oh,

Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote: Object.factory is pretty unreliable and has few supporters among the developers. I wouldn't suggest relying on it and instead building your own factory functions. oh, that's bad news, but the hibernated library is using this

Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 14:24:30 UTC, dangbinghoo wrote: On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote: On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: yeah, I made a typo mistake in the forum post, but the code in github repo is really with no typo problem.

Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote: On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: class NSconf { String name; ... } Does this class have a non-default constructor? yes, I didn't provide constructor, as Class will have a

Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
hi there, I have a set of DB entity class in a library and creating Object from another project which linked with the library returns Null. I don't know what's wrong there. the source is like this: a. I have a library with such a structure: gwlib/source/gwlib/entity/nsconf.d

Re: compiler does not detect accessing on null class object.

2019-05-27 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 27 May 2019 at 15:29:32 UTC, Daniel Kozak wrote: On Monday, 27 May 2019 at 15:13:00 UTC, dangbinghoo wrote: hello, 1.) Yes this is by design. It is not easy to detect this at compile time. It does not break safety 2.) https://dlang.org/spec/function.html#function-safety

compiler does not detect accessing on null class object.

2019-05-27 Thread dangbinghoo via Digitalmars-d-learn
hello, code below: - class a { string a1; } a a1; writeln(a1.a1); - compiles and produce "core dump" or "segfault", does this fit the original D design? why the compiler does not detect for accessing a null object and refused to compile? And, 2nd

Re: Logging best practices

2019-04-26 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 26 April 2019 at 08:10:33 UTC, Bastiaan Veelo wrote: std.experimental has been already moved to std. Are you sure about that? https://github.com/dlang/phobos/tree/master/std I think you are confusing the package std.experimental.all that moved to std. It means you can now import

Re: Logging best practices

2019-04-25 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm wrote: Hello. Is there a current "Best Practices" for logging in D? For the actual logging, I know of `std.experimental.logger`. However, the `experimental` has kept me away from it. Is it good, or are there any better

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: 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

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 {

Re: could someone test support for Asian languages in nanogui port?

2018-12-07 Thread dangbinghoo via Digitalmars-d-learn
On Sunday, 6 May 2018 at 11:18:17 UTC, drug wrote: On 06.05.2018 06:10, Binghoo Dang wrote: hi, I'm a Chinese, and I just have done the test. I also copied some Japanese text from Dlang twitter channel and added some Chinese wide punctuation Char. And It's all seems displayed correctly.

Re: D vs perl6

2018-11-22 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 22 November 2018 at 09:03:19 UTC, Gary Willoughby wrote: On Monday, 19 November 2018 at 06:46:55 UTC, dangbinghoo wrote: So, can you experts give a more comprehensive compare with perl6 and D? Sure! 1). You can actually read and understand D code. ^_^, yeah, you're right. D

D vs perl6

2018-11-18 Thread dangbinghoo via Digitalmars-d-learn
hi, What if D compared with the latest perl6? well, I know that perl6 is a VM targeted language. so which has the greater modeling-power? And perl6 seems is selling for Concurrency[1], but I think D will do this far better than a VM targeted language, right? with the pre-released version

Re: Building GUI projects with D

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn
On Saturday, 20 October 2018 at 15:40:07 UTC, karis njiru wrote: Hi. Am a computer science student from Kenya and decided to use D for my class project on Principles of Programming Languages. Am having a lot of fun with D but have come across an issue. I have been using Visual D for the past 2

Re: assigment to null class object member compiled? is this a bug?

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote: Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class object would look like "A a = new A();") Which section of The

assigment to null class object member compiled? is this a bug?

2018-10-19 Thread dangbinghoo via Digitalmars-d-learn
hi, why the code bellow compiles? --- import std.stdio; class A { int m; } void main() { A a; a.m = 1; } --- and running this code get: `segmentation fault (core dumped) ./test` I consider this couldn't be compiled according to book Programming Language>. The latest dmd

Re: Documents about ddoc? and markdown in ddoc?

2018-10-18 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 18 October 2018 at 05:59:36 UTC, rikki cattermole wrote: On 18/10/2018 6:38 PM, dangbinghoo wrote: hi, Is there any other documents related about ddoc usage? the only thing I can find is:  https://dlang.org/spec/ddoc.html#using_ddoc_to_generate_examples But I found it never

Documents about ddoc? and markdown in ddoc?

2018-10-17 Thread dangbinghoo via Digitalmars-d-learn
hi, Is there any other documents related about ddoc usage? the only thing I can find is: https://dlang.org/spec/ddoc.html#using_ddoc_to_generate_examples But I found it never mentioned something like $(LI a list item), is there a full ddoc document available? And, is there any info

Re: is there something like `stm32-rs` in D?

2018-09-26 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 26 September 2018 at 05:24:08 UTC, Radu wrote: On Wednesday, 26 September 2018 at 03:46:21 UTC, dangbinghoo wrote: hi, https://github.com/adamgreig/stm32-rs looks great, is there something like this in Dlang? thanks! --- dangbinghoo You might take a look at

is there something like `stm32-rs` in D?

2018-09-25 Thread dangbinghoo via Digitalmars-d-learn
hi, https://github.com/adamgreig/stm32-rs looks great, is there something like this in Dlang? thanks! --- dangbinghoo

Re: SerialPort

2018-09-23 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 20 September 2018 at 10:51:52 UTC, braboar wrote: I am going to play with serial port read/write, so I fetched serial-port. After that, I wrote simple program: auto port_name = "/dev/ttyUSB1"; auto reader = new SerialPort(port_name); reader.dataBits(DataBits.data8);

Re: DMD32 compiling gtkd out of memory on 32bit Windows 7 machine

2018-09-16 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 14 September 2018 at 17:34:59 UTC, Mike Wey wrote: You will also have to pass `--build=plain` to dub because of a optlink bug. https://issues.dlang.org/show_bug.cgi?id=15418 thanks Mike, I tried using `--build-plain`, optlink didn't report out of memory, but it hangs ! ```

Re: DMD32 compiling gtkd out of memory on 32bit Windows 7 machine

2018-09-13 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 12 September 2018 at 15:13:36 UTC, Timoses wrote: try `dub --build-mode=singleFile` ? I believe this will compile each file and then link them together (instead of compiling it all together what dub does, afaik). There's been another topic on memory consumption of compilation

DMD32 compiling gtkd out of memory on 32bit Windows 7 machine

2018-09-12 Thread dangbinghoo via Digitalmars-d-learn
hi , When compiling gtkd using dub, dmd32 reported "Out for memory" and exit. OS: Windows 7 32bit. RAM : 3GB DMD version: v2.0.82.0 32bit. No VC or Windows SDK installed, when setting up dmd, I selected install vc2010 and use mingw lib.

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:16:11 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: [...] try [...] thanks for

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: [...] try [...] thanks for your reply, but it will also fail, the compiler just gives me :

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: * #define SPI_MSGSIZE(N) \ N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \ ? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: hi, I'm doing a D binding myself to , and has some problems to wrap the C macros. [...] PS: if I just _IOW!(char[])... it compiles, but does it mean it's unsafe? thanks!

help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
hi, I'm doing a D binding myself to , and has some problems to wrap the C macros. ``` import core.sys.posix.sys.ioctl; ... /* IOCTL commands */ enum SPI_IOC_MAGIC = 'k'; /** * Orginal C macros. * * #define SPI_MSGSIZE(N) \ N)*(sizeof (struct spi_ioc_transfer))) < (1 <<

how to install latest lcd2 for armbain

2018-03-02 Thread dangbinghoo via Digitalmars-d-learn
hi there, I just flased a armbain for nanoPi M3. And, I just installed ldc2-1.2.0 armhf using apt-get. it compiles d code with combination with gcc armhf and compiled program runs great even the arch is aarch64. But I realized that ldc2 is too old, I know that latest ldc2 is 1.8.0. So,