Re: Does 'ref' turn into a pointer during compile time?
On 12/21/22 16:43, thebluepandabear wrote: > Say you have the following function that takes in a `ref` parameter: > > ```D > void modify(ref int num) { > num += 5; > } > ``` > > Does the compiler turn that into the code below? > > ```D > void modify(int* num) { > num += 5; Rather: *num += 5; > } > ``` > > I was just wondering whether or not this is the case because I don't > think this was touched in the book about D I am reading. Yes, references are realized by pointers by CPUs; so that's how the code is compiled as well. Pointers are considered to be one of the most difficult concepts for beginners (who the book was supposed to target). That's why I tried to hold it off as much as possible. I think once the concept of a reference is understood, pointers should be easy to understand. That's why I say "Behind the scenes, D's higher-level concepts (class variables, slices, associative arrays, etc.) are all implemented by pointers." only later in the book on the pointers page: http://ddili.org/ders/d.en/pointers.html Ali
Re: in dub single file build how to pass "-J" options?
stringImportPaths
Re: in dub single file build how to pass "-J" options?
On Thursday, 22 December 2022 at 02:19:23 UTC, mw wrote: I have example.d: ``` #!/usr/bin/env dub /+dub.sdl: dependency "tkd" version="~>1.1.14" +/ ... ``` $ dub build --single example.d ... Error: need `-J` switch to import text file `folder_page.png` I'm wondering how to pass "-J" options? Found it, it's: ``` /+dub.sdl: dependency "tkd" version="~>1.1.14" dflags "-Jmedia" +/ ``` BTW, for such single file build, do I have to use dub? is there another way to just use dmd? Still don't know how to directly invoke dmd to build.
in dub single file build how to pass "-J" options?
I have example.d: ``` #!/usr/bin/env dub /+dub.sdl: dependency "tkd" version="~>1.1.14" +/ ... ``` $ dub build --single example.d ... Error: need `-J` switch to import text file `folder_page.png` I'm wondering how to pass "-J" options? BTW, for such single file build, do I have to use dub? is there another way to just use dmd? Thanks.
Re: Does 'ref' turn into a pointer during compile time?
On Thu, Dec 22, 2022 at 12:43:28AM +, thebluepandabear via Digitalmars-d-learn wrote: > Say you have the following function that takes in a `ref` parameter: > > ```D > void modify(ref int num) { > num += 5; > } > ``` > > Does the compiler turn that into the code below? > > ```D > void modify(int* num) { > num += 5; > } > ``` > > I was just wondering whether or not this is the case because I don't > think this was touched in the book about D I am reading. Yes, a ref parameter is implemented as a pointer in the generated assembly code. But that's supposed to be an implementation detail that you generally shouldn't worry about unless you're working with low-level operations. T -- Ph.D. = Permanent head Damage
Does 'ref' turn into a pointer during compile time?
Say you have the following function that takes in a `ref` parameter: ```D void modify(ref int num) { num += 5; } ``` Does the compiler turn that into the code below? ```D void modify(int* num) { num += 5; } ``` I was just wondering whether or not this is the case because I don't think this was touched in the book about D I am reading.