Re: Passing iterators into functions

2020-06-24 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 25 June 2020 at 03:35:00 UTC, repr-man wrote: I have the code: int[5] a = [0, 1, 2, 3, 4]; int[5] b = [5, 6, 7, 8, 9]; auto x = chain(a[], b[]).chunks(5); writeln(x); It produces a range of slices as is expected: [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] However, when I define a

Passing iterators into functions

2020-06-24 Thread repr-man via Digitalmars-d-learn
I have the code: int[5] a = [0, 1, 2, 3, 4]; int[5] b = [5, 6, 7, 8, 9]; auto x = chain(a[], b[]).chunks(5); writeln(x); It produces a range of slices as is expected: [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] However, when I define a function as follows and pass in the result of the chain

Re: Arduino and MCU Support

2020-06-24 Thread Dylan Graham via Digitalmars-d-learn
On Friday, 19 June 2020 at 11:57:01 UTC, frasdoge wrote: I am looking to use D for microcontroller programming due to its benefits over C in workflow and general language features. I was wondering what the current state of this is, especially with regards to AVR. An example of the MCUs I

Re: figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/24/20 5:40 PM, kinke wrote: On Wednesday, 24 June 2020 at 21:05:12 UTC, Steven Schveighoffer wrote: I have a hard time believing that there's no way to do this! This would IMO be the job of the IDE. E.g., Visual D might be able to jump to the template declaration. Something useful

Re: figure out where a particular template function is located

2020-06-24 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 21:05:12 UTC, Steven Schveighoffer wrote: I have a hard time believing that there's no way to do this! This would IMO be the job of the IDE. E.g., Visual D might be able to jump to the template declaration.

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread matheus via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 19:46:55 UTC, IGotD- wrote: A previous game implementation in D would be interesting and if you do it you are welcome to write your about experiences here. It's hard to say what features you would take advantage in D as I haven't seen the code in C/C++. However,

Re: figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/24/20 4:38 PM, Adam D. Ruppe wrote: On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? The .mangleof the instance might help track it down since it should give you the module name as part of that mangle. Then go in

Re: figure out where a particular template function is located

2020-06-24 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? Another option would be running LDC with -vv for verbose codegen (be warned, lots and lots ouf output); we have fully qualified names in there.

Re: figure out where a particular template function is located

2020-06-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? The .mangleof the instance might help track it down since it should give you the module name as part of that mangle. Then go in there and start breaking things (or use the

Re: figure out where a particular template function is located

2020-06-24 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 24, 2020 at 04:28:24PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > I have code that instantiates a template: > > templ!int("abc"); > > When I read the source of where I *think* this template should be, I > can't find one that would match (I think). I feel like it's

figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
I have code that instantiates a template: templ!int("abc"); When I read the source of where I *think* this template should be, I can't find one that would match (I think). I feel like it's being imported elsewhere. How do I figure out what module (at least) this instantiated template is

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 19:28:15 UTC, matheus wrote: To see how the game could fit/run in D, like people are porting some of those games to Rust/Go and so on. When you mention "advantage", advantage compared to what? To the original language the game was written. For example taking

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread matheus via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 19:14:48 UTC, IGotD- wrote: On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: What I'd like to know from the experts is: What would be the advantage of using D to port such games? Can you elaborate your question a little bit more. Why would you

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: What I'd like to know from the experts is: What would be the advantage of using D to port such games? Can you elaborate your question a little bit more. Why would you want to port existing game code to another language to begin

What would be the advantage of using D to port some games?

2020-06-24 Thread matheus via Digitalmars-d-learn
Hi, I currently use D for small CLI/Batch apps, before that I used to program in C. Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there. As we can see there are a lot of old classic games source available like: DOOM, Duke

Re: Web Assembly, struct to JavaScript Object and back

2020-06-24 Thread tirithen via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 10:53:19 UTC, Sebastiaan Koppe wrote: On Tuesday, 23 June 2020 at 18:15:25 UTC, tirithen wrote: [...] Passing anything besides int/double/bool between JS and wasm is hard work. [...] Thanks for a really good explanation, passing pointers over the structs

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-24 Thread Vlad via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 12:00:04 UTC, Jacob Carlborg wrote: On Monday, 22 June 2020 at 14:32:21 UTC, Anton wrote: I have a static library (.a) compiled with LDC for iOS platform. But I can't figure out how to correctly connect it to the project and call its functions. I've already linked

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-24 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 22 June 2020 at 14:32:21 UTC, Anton wrote: I have a static library (.a) compiled with LDC for iOS platform. But I can't figure out how to correctly connect it to the project and call its functions. I've already linked binary with library to the project but IDE still doesn't see its

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-24 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 22 June 2020 at 19:41:22 UTC, Vlad wrote: Is it even possible to compile D for iOS and use it the same way as compiled C++ static library? (We do need a D runtime) Yes, druntime/Phobos will need to be linked like any other static library. -- /Jacob Carlborg

Re: Web Assembly, struct to JavaScript Object and back

2020-06-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 23 June 2020 at 18:15:25 UTC, tirithen wrote: Anyone that has something similar working with struct objects? Passing anything besides int/double/bool between JS and wasm is hard work. Currently the ABI generated by LDC is so that arguments besides int/double/bool (and

Re: opBinary : Static ifs or specialization?

2020-06-24 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 09:01:28 UTC, claptrap wrote: On Wednesday, 24 June 2020 at 00:53:58 UTC, H. S. Teoh wrote: On Tue, Jun 23, 2020 at 11:53:36PM +, claptrap via If your implementations are based on built-in operators, you could use mixins to unify the implementations into

Re: opBinary : Static ifs or specialization?

2020-06-24 Thread claptrap via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 00:53:58 UTC, H. S. Teoh wrote: On Tue, Jun 23, 2020 at 11:53:36PM +, claptrap via If your implementations are based on built-in operators, you could use mixins to unify the implementations into one, e.g.: Ah yeah thats useful, to expand a bit what about