Re: Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
I just figured out half of my frustration is caused by a collision between the 'alias this'd template possibillity and the normal one. For example: struct Bar(uint size, V) { V[size] blup; alias blup this; } void foo(S : T[], T)(S a) { pragma(msg, "first"); } void

Re: Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
On Sunday, 17 January 2021 at 16:42:27 UTC, Steven Schveighoffer wrote: I've always hated that aspect of specialization. I don't really understand why it's valid (how can T be T[]?) I totally agree with that, that confuses me as well. This works: void TFoo(T : U[], U)(T a) Oh cool, that's

Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
While trying to use template specializations I noticed the argument deductions do not yield the same version as the ones yielded when being explicit. Example: uint a = 1; uint[] b = [2]; TFoo(a); TFoo!(uint[])(b); void TFoo(T)(T a) { pragma(msg, "T: " ~ T.stringof); } void TFoo(T

Re: Template alias as template specialisation not recognized.

2021-01-15 Thread Paul via Digitalmars-d-learn
On Saturday, 16 January 2021 at 01:38:38 UTC, Paul Backus wrote: You have encountered issue 1807: https://issues.dlang.org/show_bug.cgi?id=1807 Ah I see, thank you, sad to see several DIP's I'd be interested in are postponed :( Thanks for the workaround hint, I'll probably be using that.

Template alias as template specialisation not recognized.

2021-01-15 Thread Paul via Digitalmars-d-learn
I'm having issues when trying to use a template alias as a template specialisation. When using the following: alias Vec(uint size, Type) = Mat!(size, 1, Type); void setUniform(V : Vec!(L, bool), int L)(string name, V value) {...} Vec!(4, bool) a; setUniform("test", a); I get the

Re: opCast / operator overloading with additional template arguments

2021-01-10 Thread Paul via Digitalmars-d-learn
On Monday, 11 January 2021 at 00:48:49 UTC, Steven Schveighoffer wrote: I would think though, that this should work: T opCast(T : Vec!(vecsize, S), S)() Oh wouw, this seems to work perfectly! Awesome thanks ^^ Any Idea why T opCast(T, S)() const if (is(T : Vec!(grootte, S))) { yields the

Re: opCast / operator overloading with additional template arguments

2021-01-10 Thread Paul via Digitalmars-d-learn
On Monday, 11 January 2021 at 02:37:24 UTC, Ali Çehreli wrote: >> T opCast(T)() const if (is(T : Vec!(size, S2), S2)) { The is expression can be so complicated that I used a different approach below. if (isInstanceOfVec!T && T.init.content.length == size) { // ADDED:

Re: opCast / operator overloading with additional template arguments

2021-01-10 Thread Paul via Digitalmars-d-learn
On Monday, 11 January 2021 at 00:25:36 UTC, Ali Çehreli wrote: You don't show complete code; so, I hope I came up with something that reflects your case. Thank you, sadly S (S2 now) is not any specific type, sorry I'll paste more of my file, I hope that's ok. (Sidenote, I'm not sure it's the

opCast / operator overloading with additional template arguments

2021-01-10 Thread Paul via Digitalmars-d-learn
Is there a way to have additional template arguments in operator overloads? The problem I'm having is mostly caused by casting a templated struct to other templated structs. I had the following code; T opCast(T)() const if (is(T : Vec!(vecsize, S), S)) { T converted; static

Conflict when using stderr with import.

2021-01-04 Thread Paul via Digitalmars-d-learn
I'm trying to use stderr.writefln, while using the 'bindbc-opengl' package, but when I try to I get the message: source\app.d(13,2): Error: function std.stdio.makeGlobal!"core.stdc.stdio.stderr".makeGlobal at C:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(4853,20) conflicts with variable

Re: Tuple enumeration without integers or strings

2021-01-03 Thread Paul via Digitalmars-d-learn
On Sunday, 3 January 2021 at 06:05:48 UTC, frame wrote: The hash is also generated at compile time. Is there an easy way for me to know when code is assessed / generated at compile time? For example, is indexing a constant compile time array compile time or run time? Or how about functions?

Re: Tuple enumeration without integers or strings

2021-01-02 Thread Paul via Digitalmars-d-learn
On Sunday, 3 January 2021 at 02:17:43 UTC, frame wrote: Besides the problem with equal values, what's wrong with that: alias Thing = Tuple!(int, int); enum Wind { A = Thing(0, 1), B = Thing(0, 2), C = Thing(0, 2) } void some_function(Wind w) { switch (w.hashOf) { case

Re: Tuple enumeration without integers or strings

2021-01-02 Thread Paul via Digitalmars-d-learn
On Saturday, 2 January 2021 at 21:48:04 UTC, Paul Backus wrote: Yes, but this will be true of any approach you choose. If two enum members have exactly the same value, there is no way to distinguish between them, either at compile time or at runtime. Oh I see, thanks! A bit of a bummer as I

Re: Tuple enumeration without integers or strings

2021-01-02 Thread Paul via Digitalmars-d-learn
On Saturday, 2 January 2021 at 03:20:29 UTC, Paul Backus wrote: D's switch statement only works on strings and integers. For more complex values, the easiest thing is to just use an if-else chain. If you really want to use a switch statement, you can do it by defining a function that maps

Re: Tuple enumeration without integers or strings

2021-01-01 Thread Paul via Digitalmars-d-learn
It seems w.to!string works in conjunction with Wind.N.stringof, though I wonder about the efficiency/wastefulness of this method. Sadly this also leads to very funny behavior when some of the enums have the same value, as to!string(Enum) will yield the name of the first of these enums having

Re: New integer promotion rules

2021-01-01 Thread Paul via Digitalmars-d-learn
On Thursday, 18 January 2018 at 16:31:02 UTC, ag0aep6g wrote: I'm interpreting that to mean that it will become an error for some time, but later it will be allowed again with the new behavior. And then you can throw away `-transition=intpromote`. Seeing as it's almost 3 years later, I'd like

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:27:04 UTC, H. S. Teoh wrote: foreach (key; aa.keys.sort!((a,b) => aa[a] < aa[b])) { writeln(key); This solution worked perfectly without modifying any of my other code. I don't fully understand it but can study up

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:40:23 UTC, aberba wrote: Have you tries .values() function? dictionary.values.sort() Thanks aberba. Yes, that was my first attempt! If my terminology is correct that gives me a "range" of sorted VALUES. I think I can't "iterate"(foreach) through an array

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:25:26 UTC, Paul Backus wrote: auto sorted = dictionary.byPair.array.sort!((a, b) => a.value < b.value) It seems this method produces a ?sorted array of tuples? [..Tuple!(string, "key", uint, "value")("Program", 74), Tuple!(string, "key", uint,

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
Thanks Teoh

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:25:26 UTC, Paul Backus wrote: On Wednesday, 28 October 2020 at 15:15:40 UTC, Paul wrote: per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary

Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary sorted by value not key. I can write an algorithm but is there a library method(s) I can use to iterate through the array sorted

Compile and run in Win10-VSCode

2020-09-25 Thread Paul via Digitalmars-d-learn
Hi Community, I'm Win10: I have VSCode installed. I have DMD installed and can compile examples from a Win CMD console. 1) How do I compile and run from within VSCode? 2) VSCode Extensions: Do I need them? One kept generating errors and a note said it was not under active

Re: Example uses "volatile"; compiler says "undefined identifier volatile"

2019-08-01 Thread Paul via Digitalmars-d-learn
Thank you. I'll try that.

Example uses "volatile"; compiler says "undefined identifier volatile"

2019-07-31 Thread Paul via Digitalmars-d-learn
I'm trying to build a Bare Bones 'OS' via example. Example says to compile with "gdc -c kernel.main.d -o kernel.main.o -g" I'm having trouble getting GDC all set up..as I'm a rank amateur. So, I tried compiling the example below with DMD. DMD spits out exceptions to the use of 'volatile'.

Re: Moving location of dub packages?

2019-07-21 Thread Paul via Digitalmars-d-learn
On Sunday, 21 July 2019 at 09:42:15 UTC, Andre Pany wrote: On Sunday, 21 July 2019 at 09:20:52 UTC, Andre Pany wrote: On Saturday, 20 July 2019 at 12:47:59 UTC, Paul wrote: I'd like to move where dub has stored packages to a shorter path, is there a procedure for this? Thanks in advance!

Moving location of dub packages?

2019-07-20 Thread Paul via Digitalmars-d-learn
I'd like to move where dub has stored packages to a shorter path, is there a procedure for this? Thanks in advance!

Re: Quotes inside wysiwyg strings, or alternative solution?

2019-07-18 Thread Paul via Digitalmars-d-learn
All string literals may span multiple lines. Ah, I didn't know that. Thanks for the detailed reply!

Quotes inside wysiwyg strings, or alternative solution?

2019-07-18 Thread Paul via Digitalmars-d-learn
Hi, I have searched, but can't find a solution. In C++ and Rust there is the option of enclosing a string in a sequence of chars (after R/r) to allow quotation marks in multiline string literals. What is the solution in D for wysiwyg strings (or similar) spanning multiple lines containing

Re: How to concatenate a tuple of strings at compile time?

2018-01-06 Thread paul via Digitalmars-d-learn
Thanks for the input. Unfortunately I still can't convince the compiler. __traits allMembers includes functions. Trying to filter those with std.traits.isCallable, it complains about strings that can't be read or fields that can't be accessed at compile time. Affected are both solutions.

How to concatenate a tuple of strings at compile time?

2018-01-06 Thread paul via Digitalmars-d-learn
Hi! How to concatenate a tuple of strings at compile time? Appending to an enum or an immutable string in a static foreach doesn't work. (And shadowing the thing doesn't work either) a) Calling a function recursively doesn't work because I had to turn the tuple into an array which cannot be

Re: Initialise dynamic array in array of structures

2016-06-22 Thread Paul via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 19:33:31 UTC, cym13 wrote: ... but “trackTemplates[0].coords = [{0, 9}, {1, 1}, {3, 6}];” is an assignment so the compiler can infer as much and doesn't understand that each of those list of values are really CoordLists. I see, but it seems a bit strange given that

Initialise dynamic array in array of structures

2016-06-21 Thread Paul via Digitalmars-d-learn
Given these structures and declaration: struct CoordList{ int x, y; } struct Part{ int x, y; CoordList[] coords; int nextNode, prevNode; string nextEnter, prevEnter; } Part[10] trackTemplates; Can someone please tell me why I can't initialise

Re: ref parameter qualifier and static arrays

2015-09-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 20:35:53 UTC, anonymous wrote: When you pass a slice (without ref), what's actually passed is a pointer and length. The contents are not copied. That means, when you alter an array element, the change will be done the original, even without ref: Thanks

ref parameter qualifier and static arrays

2015-09-09 Thread Paul via Digitalmars-d-learn
Is it possible to call a function like this... void foo(ref int[] anArray) ...with slices of static arrays? I thought I might be able to use [0..$-1] but to no avail - I get an error like this (which is confusing!): (ref int[] anArray) is not callable using argument types (int[]) I've

Re: Superfluous code in switch statement

2015-09-05 Thread Paul via Digitalmars-d-learn
On Friday, 4 September 2015 at 21:20:11 UTC, Timon Gehr wrote: On 09/04/2015 11:12 PM, anonymous wrote: On Friday 04 September 2015 23:04, Timon Gehr wrote: DMD never warns about dead code. It warns here: import std.stdio; void main() { return; writeln("hi"); /* Warning:

Superfluous code in switch statement

2015-09-04 Thread Paul via Digitalmars-d-learn
I discovered the other day (during a cut and paste malfunction!) that it's possible to have code before the first case in a switch. Google tells me that it's legal C code and something I read said it could be used for initialization but was rather vague. void main() { import std.stdio;

Re: tkd - basic compilation problem

2015-07-02 Thread Paul via Digitalmars-d-learn
On Thursday, 2 July 2015 at 17:41:45 UTC, Gary Willoughby wrote: This is exactly why you use dub, so you don't have to worry about all this! You're right, there's sufficient information there if using dub.

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 09:38:05 UTC, Marc Schütz wrote: Someone more familiar with Debian/Ubuntu than me may be able to help you here, sorry. I was hoping to keep a tight rein on what was required to be installed to simplify deployment but its spiraling out of control again LOL. The

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:43:11 UTC, Gary Willoughby wrote: On Tuesday, 30 June 2015 at 12:58:21 UTC, Paul wrote: ... I really don't understand posts like this when literally all information needed is in the README file: https://github.com/nomad-software/tkd Just read RTFM. I read

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 18:38:27 UTC, Jordi Sayol wrote: For shared linking against libphobos2.so and libtkd.so: $ dmd `pkg-config --cflags --libs tkd` -J/usr/share/libtkd-doc/example/media/ /usr/share/libtkd-doc/example/example.d For static linking against libphobos2.a and libtkd.a: $

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 16:06:41 UTC, Marc Schütz wrote: On Tuesday, 30 June 2015 at 15:25:27 UTC, Alex Parrill wrote: On Tuesday, 30 June 2015 at 14:28:49 UTC, Paul wrote: Using dub I get this during linking: Building tkd-test ~master configuration application, build type debug.

Re: tkd - basic compilation problem

2015-06-30 Thread Paul via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 13:22:43 UTC, Paul wrote: On Tuesday, 30 June 2015 at 13:19:25 UTC, Marc Schütz wrote: If you don't want to use DUB, you need to download the other two packages from code.dlang.org and specifiy -I/path/to/tcltk -I/path/to/x11 -I/path/to/tkd in the DMD invocation.

Re: tkd - basic compilation problem

2015-06-30 Thread Paul via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 13:19:25 UTC, Marc Schütz wrote: If you don't want to use DUB, you need to download the other two packages from code.dlang.org and specifiy -I/path/to/tcltk -I/path/to/x11 -I/path/to/tkd in the DMD invocation. Thank you, I'll try that.

tkd - basic compilation problem

2015-06-30 Thread Paul via Digitalmars-d-learn
I downloaded the archive from https://github.com/nomad-software/tkd and files are same as in the git repo. Tcl/tk is installed on this machine (test 'hello world' script works fine) but I get this error when compiling the example from the github page: tkd/interpreter/tcl.d(16): Error: module

Re: tkd - basic compilation problem

2015-06-30 Thread Paul via Digitalmars-d-learn
Using dub I get this during linking: Building tkd-test ~master configuration application, build type debug. Compiling using dmd... Linking... /usr/bin/ld: cannot find -ltcl /usr/bin/ld: cannot find -ltk ...any suggestions please?

Re: Array declaration warning

2015-06-03 Thread Paul via Digitalmars-d-learn
On Wednesday, 3 June 2015 at 20:33:02 UTC, Ali Çehreli wrote: pathList[][n] ~= CoOrd(cX, cY); I don't think you need the empty [] there. pathList[n] is one of the paths and you are adding a coordinate to it: Urgh, *that* is how I was confusing myself, the rest of the code 'looks right'.

Re: Linker command

2015-05-06 Thread Paul via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 20:03:36 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:52:44 UTC, Paul wrote: On Wednesday, 6 May 2015 at 19:30:33 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag

Re: Linker command

2015-05-06 Thread Paul via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 12:41:21 UTC, wobbles wrote: On Monday, 4 May 2015 at 20:34:32 UTC, Paul wrote: Can some one tell me what this linker command means (or point me at some docs) please: dmd example.d -L-L. $@ AFAIK $@ is 'all the supplied arguments' so I don't understand what it

Re: Linker command

2015-05-06 Thread Paul via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 19:52:44 UTC, Paul wrote: On Wednesday, 6 May 2015 at 19:30:33 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag but what is '-L-L.' doing?? Passes '-L.' to the linker.

Re: Linker command

2015-05-06 Thread Paul via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 19:30:33 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag but what is '-L-L.' doing?? Passes '-L.' to the linker. :D I can see that, but what does '-L.' mean exactly?

Linker command

2015-05-04 Thread Paul via Digitalmars-d-learn
Can some one tell me what this linker command means (or point me at some docs) please: dmd example.d -L-L. $@ AFAIK $@ is 'all the supplied arguments' so I don't understand what it achieves. (it's from the DAllegro5 example program, on Linux). Cheers, Paul

Re: Implicit conversion error

2015-05-01 Thread Paul via Digitalmars-d-learn
On Thursday, 30 April 2015 at 22:24:15 UTC, bearophile wrote: Paul: When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); .length returns a size_t, and 0 is an int. uniform() probably decides to unify those types to a size_t. A size_t is 32 bit on 32 bit machines

Implicit conversion error

2015-04-30 Thread Paul via Digitalmars-d-learn
When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); gives me an error: Error: cannot implicitly convert expression (uniform(0, mobs.length)) of type ulong to int but it compiles ok on a 32 bit machine. I thought it was the expression on the righthand side returning

How to output ascii character using terminal.d

2015-04-24 Thread Paul via Digitalmars-d-learn
How do I output a single ascii character specified numerically, via terminal.d's writef() function which expects a string? Bound to be something obvious but I just can't see it atm! Paul

Re: How to output ascii character using terminal.d

2015-04-24 Thread Paul via Digitalmars-d-learn
On Friday, 24 April 2015 at 15:46:15 UTC, Adam D. Ruppe wrote: Try terminal.writef(%s, cast(char) your_ascii_character); it should work. Thank you, it works for the standard ascii characters but not the extended set - maybe that has something to do with my terminal settings...? (not that I

Re: string-int[] array

2015-03-08 Thread Paul via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, five]; As there's no mention of performance, what's wrong with a plain old string array with a bit of

Re: string-int[] array

2015-03-08 Thread Paul via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:18:31 UTC, Max Klyga wrote: On 2015-03-08 21:11:42 +, Paul said: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4,

Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
I'd like to create a Terminal using terminal.d and make it available across several source files (as a global rather than having to pass it around) but when I define it like this in global scope: Terminal Screen = Terminal(ConsoleOutputType.cellular); I get this error: Error: getenv cannot

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:35:27 UTC, H. S. Teoh wrote: On Tue, Feb 17, 2015 at 07:17:41PM +, Paul via Digitalmars-d-learn wrote: I'd like to create a Terminal using terminal.d and make it available across several source files (as a global rather than having to pass it around

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:29:52 UTC, Adam D. Ruppe wrote: On Tuesday, 17 February 2015 at 19:17:42 UTC, Paul wrote: I don't understand the error and Google doesn't help - can it be fixed or am I just using the wrong approach? Trying to create it as a global tries to make it as a

Re: Ncurses deprecated ~master issue

2015-02-11 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 23:39:56 UTC, Adam D. Ruppe wrote: On Tuesday, 10 February 2015 at 21:11:14 UTC, Paul wrote: Yes, I noted the default values, even if I don't understand what they do at present(!). They allow overriding of the input/output files. fdIn normally refers to

Re: Ncurses deprecated ~master issue

2015-02-11 Thread Paul via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 18:37:49 UTC, Adam D. Ruppe wrote: On Wednesday, 11 February 2015 at 18:13:10 UTC, Paul wrote: How do I get/process input? Construct the real time input struct outside your loop then use getch if you're only interested in the core keyboard ascii stuff or

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working.

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 20:57:43 UTC, Adam D. Ruppe wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' If you see 'undefined reference' it means some library

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 21:05:08 UTC, Meta wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 3 December 2014 at 19:37:03 UTC, Paul wrote: On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use

Re: Conway's game of life

2015-02-03 Thread Paul via Digitalmars-d-learn
On Monday, 2 February 2015 at 16:58:43 UTC, bearophile wrote: The quality of the D GC is not important for a simple Life implementation, you just need two arrays. Here's my 30 minute sandwich-break version, sorry it's not very arractive 'D'... import std.stdio; import std.random; void

Re: Conway's game of life

2015-02-03 Thread Paul via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 13:35:37 UTC, Paul wrote: On Monday, 2 February 2015 at 16:58:43 UTC, bearophile wrote: The quality of the D GC is not important for a simple Life implementation, you just need two arrays. Here's my 30 minute sandwich-break version, sorry it's not very

Re: Conway's game of life

2015-02-03 Thread Paul via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 14:01:51 UTC, bearophile wrote: Paul: enum WORLDSIZE = 20; enum INITIALPOP = 70; //experimental enum DEAD = 0; enum ALIVE = 1; D enums don't need to be ALL UPPERCASE :-) int world[WORLDSIZE][WORLDSIZE]; Don't

Re: Input error with readf()

2015-01-30 Thread Paul via Digitalmars-d-learn
On Friday, 30 January 2015 at 15:03:55 UTC, Ali Çehreli wrote: Not the best error message... Saying '5' is unexpected for 'int' is confusing, right? Unfortunately, I can't come up with a good explanation for that error message in the book. :) Maybe just remove the section with the

std.algorithm sort() and reverse() confusion

2015-01-30 Thread Paul via Digitalmars-d-learn
Given that myVals is a dynamic array of ints... writeln(Array contents: , myVals); writeln(Sorted: , sort(myVals)); writeln(Sorted, reversed: , reverse(myVals)); Gives me... Error: template std.stdio.writeln cannot deduce function from argument types !()(string, void) But, if I bring the

Re: std.algorithm sort() and reverse() confusion

2015-01-30 Thread Paul via Digitalmars-d-learn
On Friday, 30 January 2015 at 16:21:24 UTC, Kagamin wrote: writeln(Sorted, reversed: , retro(sort(myVals))); ? Or... writeln(Reverse sorted: , sort!(a b)(vals)); but I still don't understand the original 'error'.

Re: std.algorithm sort() and reverse() confusion

2015-01-30 Thread Paul via Digitalmars-d-learn
On Friday, 30 January 2015 at 18:46:55 UTC, Ali Çehreli wrote: there is no such benefit with reverse, so there's no need to return anything. Still, returning the original range would help with chaining calls: arr.reverse.map!sqrt Side note: There is the confusion between the .reverse

Input error with readf()

2015-01-30 Thread Paul via Digitalmars-d-learn
If I run the following example program from the 'Programming in D' book, the input doesn't 'get stuck' as stated in the book but instead produces the error message given. Have things changed since that part of the book was written or is it some other issue? The version that uses %s in the call

Re: Print to Win Printer

2015-01-28 Thread Paul via Digitalmars-d-learn
Thanks Vladimir.

Print to Win Printer

2015-01-27 Thread Paul via Digitalmars-d-learn
How do I print to a Windows printer from a console program? Thanks for your assistance.

Re: Sqlite

2015-01-25 Thread Paul via Digitalmars-d-learn
I'd like to vary the query based on input but if I try to move the string out of the sqlite3_exec call like this: string sqlStatement = CREATE TABLE people(id INT PRIMARY KEY NOT NULL, surname TEXT NOT NULL);; result = sqlite3_exec(db, sqlStatement, aCallback, null, msg); ...it won't

Re: Sqlite

2015-01-25 Thread Paul via Digitalmars-d-learn
On Sunday, 25 January 2015 at 18:19:47 UTC, Tobias Pankrath wrote: Only string literals convert to const(char)*, because only for them it is guaranteed that they are null terminated. For everything else use toStringz. So, as a trivial example, is this how it's done?: string semiC = ;; const

Sqlite

2015-01-11 Thread Paul via Digitalmars-d-learn
Can someone please tell me what I'm doing wrong here, the sql INSERT statement fails for some reason. I don't fully understand the callback function yet (I borrowed this from a C tutorial on the subject), maybe that is the source of the problem? import etc.c.sqlite3; import std.stdio;

Re: Sqlite

2015-01-11 Thread Paul via Digitalmars-d-learn
On Sunday, 11 January 2015 at 20:20:21 UTC, ketmar via Digitalmars-d-learn wrote: note the single quotes in your code: that is where it all goes wrong. i don't know where you got that quotes from, but this is not a valid SQL syntax for `CREATE TABLE`. ;-) Thank you, I thought it might be

Re: Sqlite

2015-01-11 Thread Paul via Digitalmars-d-learn
On Sunday, 11 January 2015 at 22:19:28 UTC, Tobias Pankrath wrote: Hint: Put the SQL in a file create_people.sql and import it into your code via the import statement: string sql = import(create_people.sql); // you'll need a correct -J compiler switch That way you can easily test if it's

Re: Segmentation fault after having a certain number of elements in an array?

2014-12-13 Thread Paul via Digitalmars-d-learn
On Saturday, 13 December 2014 at 08:59:19 UTC, Jeremy DeHaan wrote: for(int i = 0; isamples.length; ++i) m_samples.length +=1; You are testing i against an ever-increasing limit aren't you, so it's an infinite loop.

Re: Global array

2014-12-12 Thread Paul via Digitalmars-d-learn
On Thursday, 11 December 2014 at 21:35:43 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Dec 11, 2014 at 08:56:00PM +, Paul via Digitalmars-d-learn wrote: Is there any merit (or folly!) in storing a large array, that frequently needs to be accessed globally, within a class like so

Re: Derelict / SDL error

2014-12-11 Thread Paul via Digitalmars-d-learn
On Thursday, 11 December 2014 at 00:36:08 UTC, Mike Parker wrote: More evidence pointing toward the system configuration on the problem machines. I'm quite far from being a Linux guru, but at this point I would be looking at removing the binaries I've compiled myself and installing the binary

Global array

2014-12-11 Thread Paul via Digitalmars-d-learn
Is there any merit (or folly!) in storing a large array, that frequently needs to be accessed globally, within a class like so: public class classMap{ public static int[MAPSIZE][MAPSIZE] map; } Or is there a proper 'D' way to do this? TIA

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 22:27:43 UTC, anonymous wrote: On Tuesday, 9 December 2014 at 16:12:35 UTC, Paul wrote: import derelict.sdl2.sdl; import std.stdio; import std.conv; void main() { scope(exit) { SDL_Quit(); } DerelictSDL2.load();

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 12:10:23 UTC, Mike Parker wrote: Also, though this is unrelated (I just noticed it when looking at your code again), I strongly recommend you move the line scope( exit ) SDL_Quit(); to somewhere after DerelictSDL2.load(). If the SDL shared library fails to

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 09:07:56 UTC, ketmar via Digitalmars-d-learn wrote: do you have the corresponding libraries installed? SDL_Image uses libpng and libjpeg for decoding images, so if you don't have those installed (with corresponding -dev if your system needs that) you will not

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 16:58:57 UTC, Mike Parker wrote: On 12/11/2014 12:31 AM, Paul wrote: This thread has degenerated into a discussion of the set up of my OS which is miles off topic and should probably be abandoned. Maybe not. The trouble is that others have been able to

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 18:06:08 UTC, Paul wrote: On Wednesday, 10 December 2014 at 16:58:57 UTC, Mike Parker wrote: On 12/11/2014 12:31 AM, Paul wrote: This thread has degenerated into a discussion of the set up of my OS which is miles off topic and should probably be abandoned.

Re: Derelict / SDL error

2014-12-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 18:58:15 UTC, Paul wrote: The two machines on which errors occur are a Mint 13 (32 bit) box and an ageing laptop with Lubuntu 14.04. I've followed the same procedures but the 64 bit obviously has the 64 bit dmd compiler. Just added SDL_image to this 64 bit

Re: Derelict / SDL error

2014-12-09 Thread Paul via Digitalmars-d-learn
On Monday, 8 December 2014 at 21:01:40 UTC, Paul wrote: On Monday, 8 December 2014 at 17:48:55 UTC, Jack wrote: I'm running ArchLinux 64-bit on Vbox and tested out the code. There haven't been any problems. Have you tried updating whatever tools you're using?(dmd, dub, etc) Might've been

Re: Derelict / SDL error

2014-12-09 Thread Paul via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 13:34:56 UTC, Jack wrote: Can't really think of anything that can solve your problem. Only time I had a seg fault is calling a method from an uninitialized class. You can try to get a debugger and/or a gui that comes with it(personally I use gdb with ddd) to find

Re: Derelict / SDL error

2014-12-09 Thread Paul via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 15:40:00 UTC, Mike Parker wrote: On 12/10/2014 12:19 AM, Paul wrote: dub doesn't know anything about DerelictSDL2Image (and even if it did, just importing it isn't going to tell dub about it -- you would need to add it to your dub.json as a dependency). That's

Re: Derelict / SDL error

2014-12-09 Thread Paul via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 15:48:32 UTC, Paul wrote: On Tuesday, 9 December 2014 at 15:40:00 UTC, Mike Parker wrote: On 12/10/2014 12:19 AM, Paul wrote: dub doesn't know anything about DerelictSDL2Image (and even if it did, just importing it isn't going to tell dub about it -- you would

Re: Derelict / SDL error

2014-12-09 Thread Paul via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 15:53:11 UTC, Paul wrote: Whoa, I read that wrong - I'm sure I tried just adding DerelictSDL2Image.load() to my program an it didnt work. Trying again. The top of my app.d looks like this: import derelict.sdl2.sdl; import std.stdio; import std.conv; void

Derelict / SDL error

2014-12-08 Thread Paul via Digitalmars-d-learn
Sorry this is a bit off topic but as there doesn't seem to be an active forum for Derelict atm This simple test code is giving me an error 'Error executing command run: Program exited with code -11' (or a seg fault if executed from a terminal). The problem line is:

Re: Derelict / SDL error

2014-12-08 Thread Paul via Digitalmars-d-learn
On Monday, 8 December 2014 at 13:08:58 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 08 Dec 2014 12:53:10 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Sorry this is a bit off topic but as there doesn't seem to be an active forum for Derelict atm

Re: Derelict / SDL error

2014-12-08 Thread Paul via Digitalmars-d-learn
On Monday, 8 December 2014 at 13:23:12 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 08 Dec 2014 13:16:37 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 8 December 2014 at 13:08:58 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 08 Dec 2014

  1   2   >