Re: How can I distinguish an enum constant from an actual enum at compile time?

2015-10-30 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 30 October 2015 at 12:18:21 UTC, Gary Willoughby wrote: On Friday, 30 October 2015 at 12:03:50 UTC, TheFlyingFiddle wrote: pragma(msg, is(b == enum)); //True pragma(msg, is(a == enum)); //False. enum isEnum(alias e) = is(e == enum); isEnum!(a) isEnum!(b) ;) isEnum!(isEnum)

Re: How can I distinguish an enum constant from an actual enum at compile time?

2015-10-30 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 30 October 2015 at 12:03:50 UTC, TheFlyingFiddle wrote: pragma(msg, is(b == enum)); //True pragma(msg, is(a == enum)); //False. enum isEnum(alias e) = is(e == enum); isEnum!(a) isEnum!(b) ;)

How to install DMD 64bit on Windows?

2015-10-21 Thread Gary Willoughby via Digitalmars-d-learn
How to install DMD 64bit on Windows? Is it just a case of downloading from here and it just works? http://dlang.org/download.html Or do I need Visual Studio installed?

Writing a screen saver in D what libraries will help?

2015-10-12 Thread Gary Willoughby via Digitalmars-d-learn
If I was writing a screensaver in D what libraries are available for opening a window and drawing sprites, etc on it. GPU accelerated if possible. I'm using Ubuntu 14.04 and latest DMD compiler.

Re: Writing a screen saver in D what libraries will help?

2015-10-12 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 12 October 2015 at 19:16:10 UTC, Gary Willoughby wrote: If I was writing a screensaver in D what libraries are available for opening a window and drawing sprites, etc on it. GPU accelerated if possible. I'm using Ubuntu 14.04 and latest DMD compiler. I've found Dgame which looks

Re: DMD Compiler 'switches'

2015-10-12 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 12 October 2015 at 15:38:27 UTC, ric maicle wrote: I'm relearning D. I'm using the reference compiler (DMD) and I am a bit confused with how the compiler 'switches' are supposed to be used. I find some 'switches' that require an equal (=) symbol when a value is required to be

Re: Mac IDE with Intellisense

2015-09-26 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 26 September 2015 at 09:17:10 UTC, Mike McKee wrote: I was doing toHexString(myByteArray) instead of simply doing myByteArray.toHexString(). (That was on an md5 example, by the way.) Intellisense would have helped me realize this. Both these forms are the same. It's called UFCS

Re: mysql-native: SQL Transaction support?

2015-09-17 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:47:33 UTC, salvari wrote: I'm parsing a text input file, the generated sql is about 1 million lines of SQL. By using mysql-native it takes about 4 hours to load data. I've used mysql-native before to handle hundreds of millions of rows of data and I

Re: How do I change debug mode with dub?

2015-09-16 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 10:42:13 UTC, Alex_Freeman wrote: Hey all! I'm just wondering how to run dub with different debug versions, or running it with different versions generally? Is there also a way to have code behind multiple debug versions, or run more than one debug version at

Re: tkd not linking

2015-09-15 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 17:37:40 UTC, karabuta wrote: I have tried several times to compile tkd using dub but I keep getting this message: Linking... /usr/bin/ld: cannot find -ltcl /usr/bin/ld: cannot find -ltk It looks like the libraries are not installed or not installed

Re: D + Dub + Sublime +... build/run in terminal?

2015-09-13 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 13 September 2015 at 10:00:13 UTC, SuperLuigi wrote: but whatever I put in messes up and I just get errors... So what are the errors?

Re: private selective import not so private ?

2015-09-11 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:55:41 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 00:52:00 UTC, BBasile wrote: While trying to get why some call to memmove without the right import didn't lead to a compilation failure i've found that imported symbols are not private ! Is that

Re: Hello World Example with Glade?

2015-09-11 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 11 September 2015 at 07:13:22 UTC, Mike McKee wrote: I'm having trouble installing GtkD on Ubuntu Linux 14.04. Here's an old guide I wrote years ago. It might be a little out of date but may help you put things together:

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: - RefCounted Only for D structs. std::shared_ptr works for all. RefCounted works with classes as well. http://dlang.org/phobos/std_typecons.html#.RefCounted

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 10 September 2015 at 12:34:54 UTC, Daniel Kozák wrote: On Thu, 10 Sep 2015 11:38:35 + "Gary Willoughby" wrote: On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: > - RefCounted > > Only for D structs. std::shared_ptr works for all. RefCounted works

Re: Better unittest failure output

2015-09-07 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 7 September 2015 at 11:57:25 UTC, Bahman Movaqar wrote: I am working on a simple project created with DUB[1]. When unit tests the output reads really cryptic to me; for example: Try using DUnit, it gives you much more readable fail messages: https://github.com/nomad-software/dunit

Re: Better unittest failure output

2015-09-07 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 7 September 2015 at 12:58:58 UTC, Gary Willoughby wrote: On Monday, 7 September 2015 at 11:57:25 UTC, Bahman Movaqar wrote: I am working on a simple project created with DUB[1]. When unit tests the output reads really cryptic to me; for example: Try using DUnit, it gives you much

Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-06 Thread Gary Willoughby via Digitalmars-d-learn
Are there any Phobos functions to check file permissions on Windows and Posix? For example, I want to check if a file is readable and/or writable in a cross-platform fashion. Does anyone have an example?

Re: how does vibe's PrivateAccessProxy work

2015-08-31 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 31 August 2015 at 01:56:05 UTC, yawniek wrote: can someone explain a bit how the @before hooks works in detail, i mainly have problems understanding why ensureAuth in belows example refers to "SampleService." as an instance:

Re: Reading and converting binary file 2 bits at a time

2015-08-30 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 30 August 2015 at 00:02:16 UTC, anonymous wrote: On Saturday, 29 August 2015 at 23:34:47 UTC, Gary Willoughby wrote: But it might not be safe: http://forum.dlang.org/thread/ztefzijqhwrouzlag...@forum.dlang.org That link just takes me to this thread here again. Here's the correct

Re: Reading and converting binary file 2 bits at a time

2015-08-29 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 29 August 2015 at 21:50:12 UTC, Mike James wrote: On Saturday, 29 August 2015 at 20:15:53 UTC, Marc Schütz wrote: Just cast to `Crumbs[]` directly: import std.bitmanip; import std.stdio; import std.file; struct Crumbs { mixin(bitfields!( ubyte,

Re: Reading and converting binary file 2 bits at a time

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 August 2015 at 12:40:07 UTC, Mike James wrote: How about... A lot nicer. :)

Re: What is this function call operator?

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 August 2015 at 16:12:35 UTC, Adam D. Ruppe wrote: On Thursday, 27 August 2015 at 16:03:58 UTC, Gary Willoughby wrote: Sorry, I mean the three dots '...' that seems to be what the documentation is referring to. Also the `isCallable` template uses it. That just means it can

What is this function call operator?

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
If you visit this link: http://dlang.org/phobos/std_traits.html#isCallable There is this paragraph: Detect whether T is a callable object, which can be called with the function call operator (...). What is this function call operator? (...) Where can i learn more about it?

Re: What is this function call operator?

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 August 2015 at 15:19:15 UTC, Adam D. Ruppe wrote: On Thursday, 27 August 2015 at 15:18:24 UTC, Gary Willoughby wrote: What is this function call operator? (...) Where can i learn more about it? It is the () at the end of a thing. You can overload it in a struct by writing an

Re: Arrays of structs

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 August 2015 at 10:49:02 UTC, John Burton wrote: Thanks again for the updates. I've experimented some more and believe I understand. To be honest I'm finding it very hard to find the right idioms in D for safe and efficient programming when I'm so used to C++ / RAII

Re: Reading and converting binary file 2 bits at a time

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 August 2015 at 09:38:52 UTC, Andrew Brown wrote: On Thursday, 27 August 2015 at 09:26:55 UTC, rumbu wrote: On Thursday, 27 August 2015 at 09:00:02 UTC, Andrew Brown wrote: Hi, I need to read a binary file, and then process it two bits at a time. But I'm a little stuck on the

Re: Casting pointers

2015-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 26 August 2015 at 12:14:54 UTC, John Burton wrote: This would be undefined behavior in c++ due to aliasing rules on pointers. It appears to work reliably in D when I try it, but that's obviously no guarantee that it's correct or will continue to do so. Is this correct code in

Re: How to use ranges?

2015-08-23 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 23 August 2015 at 17:58:44 UTC, Doolan wrote: ... Read this for a nice introduction: http://ddili.org/ders/d.en/ranges.html Then watch this: https://www.youtube.com/watch?v=A8Btr8TPJ8c

Re: InstanceOf Template during runtime in a variant

2015-08-06 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 3 February 2014 at 19:47:56 UTC, Dicebot wrote: On Monday, 3 February 2014 at 19:35:47 UTC, Andre wrote: Btw. having std.decimal in the library would be really nice;) Kind regards André There is a proposal in Phobos review queue (http://wiki.dlang.org/Review_Queue) but its author

Re: Calling Syntax (no, not UFCS)

2015-08-04 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see

Re: Is Key Type?

2015-08-02 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 2 August 2015 at 17:55:16 UTC, Xinok wrote: is there a trait in D or Phobos which will tell you if a type can be used as a key for an associative array? For example, where T is some type: static assert(isKeyType!T) int[T] hashTable = ... import std.stdio; enum

Re: Where can i find examples of multi-threaded fibers?

2015-07-27 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 27 July 2015 at 08:00:10 UTC, Marc Schütz wrote: On Sunday, 26 July 2015 at 18:07:51 UTC, Gary Willoughby wrote: In the description for Fiber in std.thread is the following[1]: Please note that there is no requirement that a fiber be bound to one specific thread. Rather, fibers may

Re: GC stats

2015-07-26 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 25 July 2015 at 17:43:44 UTC, Martin Nowak wrote: On Saturday, 25 July 2015 at 17:34:26 UTC, Márcio Martins wrote: What I want is a clean non-intrusive way to log when a collection happened, how long my threads were stopped, how much total memory and how many blocks were

Where can i find examples of multi-threaded fibers?

2015-07-26 Thread Gary Willoughby via Digitalmars-d-learn
In the description for Fiber in std.thread is the following[1]: Please note that there is no requirement that a fiber be bound to one specific thread. Rather, fibers may be freely passed between threads so long as they are not currently executing. How would this be accomplished and are there

Re: Where can i find examples of multi-threaded fibers?

2015-07-26 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 26 July 2015 at 19:51:08 UTC, Ali Çehreli wrote: On 07/26/2015 11:07 AM, Gary Willoughby wrote: In the Thanks for the example. I'll study it.

Re: Passing struct and struct[] into a template

2015-07-23 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 04:29:26 UTC, Taylor Gronka wrote: Hi, I have a template function, and I want it to do something if the input variable is a list of structs, and something else if the input is a struct. [...] Take a look at this thread, the poster had the same question:

Re: How do i sanitize a string for database query?

2015-07-21 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote: How do i sanitize a string for database query? Is there some builtin function? thx :) Use prepared statements instead. https://en.wikipedia.org/wiki/Prepared_statement

Re: How do i sanitize a string for database query?

2015-07-21 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 18:55:53 UTC, ddos wrote: On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote: On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote: How do i sanitize a string for database query? Is there some builtin function? thx :) Use prepared statements instead.

Re: Template function that accept strings and array of strings

2015-07-16 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote: Hello, I can't figure how to write a template function that accept either strings or array of strings. This is my current code: bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char) || (isArray!T

Re: Template function that accept strings and array of strings

2015-07-16 Thread Gary Willoughby via Digitalmars-d-learn
Also checkout inout functions: http://dlang.org/function.html#inout-functions

opApply compilation woes

2015-07-12 Thread Gary Willoughby via Digitalmars-d-learn
Why does the following code fail to compile if the `writeln(value);` line is present? public template ForeachAggregate(T) { alias ForeachAggregate = int delegate(ref T) nothrow; } unittest { import std.stdio; class Foo { private string[] _data =

Re: opApply compilation woes

2015-07-12 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 12 July 2015 at 17:33:50 UTC, anonymous wrote: On Sunday, 12 July 2015 at 17:25:17 UTC, Gary Willoughby wrote: Why does the following code fail to compile if the `writeln(value);` line is present? The error message (formatted to be a little more readable): Error: function

Re: Check an entire XML document for well-formedness in KXML

2015-07-08 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 8 July 2015 at 07:30:51 UTC, Sergey wrote: Hello! I try to use KXML and I need very simple: check an entire XML document for well-formedness. How is it better to do? Thanks in advance. Maybe use the command line: $ sudo apt-get install libxml2 $ xmllint --schema schema.xsd

Re: Correctly implementing a bidirectional range on a linked list?

2015-07-07 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 09:35:12 UTC, Jonathan M Davis wrote: This is why you almost never use @trusted on templated functions. You should _never_ mark anything with @trusted unless you can guarantee that it's actually @safe. @safe is inferred for templated functions, so unless you're doing

Correctly implementing a bidirectional range on a linked list?

2015-07-06 Thread Gary Willoughby via Digitalmars-d-learn
How do you correctly implement a bidirectional range on a linked list? I have a linked list implementation and I've added a range interface to it but after a while I've realized it not quite right. The problem is when I call the save method of the forward range interface I don't get a copy I

Re: ddoc - modules with same name

2015-07-02 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 2 July 2015 at 06:33:42 UTC, armando sano wrote: I could never get this working. Have you got an example of your compiler command. In case that's still helpful after a couple of years...: dmd path1/to/source.d path2/to/source.d -o- -D -Ddpath/to/doc -op generates

Re: tkd - basic compilation problem

2015-07-02 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 19:45:04 UTC, Paul wrote: I can't see how they answer the questions I've asked. Let me see. On Tuesday, 30 June 2015 at 12:58:21 UTC, Paul wrote: I downloaded the archive from https://github.com/nomad-software/tkd and files are same as in the git repo. Tcl/tk is

Re: tkd - basic compilation problem

2015-07-02 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 2 July 2015 at 18:34:13 UTC, Paul wrote: 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. Please read that page again.

Re: tkd - basic compilation problem

2015-07-01 Thread Gary Willoughby via Digitalmars-d-learn
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.

Re: Nullable with reference types

2015-06-30 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 29 June 2015 at 19:29:37 UTC, sigod wrote: Hi, everyone. ``` import std.typecons : Nullable; class Test {} Nullable!Test test; assert(test.isNull); ``` Why does `Nullable` allowed to be used with reference types (e.g. classes)? P.S. I have experience with C#, where `NullableT`

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 29 June 2015 at 20:12:12 UTC, Assembly wrote: I believe it's a design choice, if so, could someone explain why? is immutable better than C#'s readonly so that the readonly keyword isn't even needed? for example, I'd like to declare a member as readonly but I can't do it directly

Re: Check if template has been passed a reference type or value type?

2015-06-25 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 7 June 2015 at 15:17:27 UTC, 1967 wrote: I've got a template that takes in a type. Sometimes the type is a class, sometimes a struct, sometimes just an int. It doesn't much matter what it is, but if it's a reference type I need to check if it's null so I can make it not null before

Re: @property on free function for UFCS?

2015-06-14 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 14 June 2015 at 12:53:43 UTC, rcorre wrote: Is there a good reference for the current state of @property? I know it was hotly debated for awhile (and maybe still is?). I'm just never sure when I should be using it (if at all). Oh yes:

Re: Dual conditions in D and Python

2015-05-21 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 21 May 2015 at 18:26:28 UTC, Dennis Ritchie wrote: elif instead of else if: http://rextester.com/WOSH30608 The parallel exchange values: http://rextester.com/TPUD51604 wow!

Re: overloading evaluation (treating objects as functions)

2015-05-18 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 17 May 2015 at 18:58:32 UTC, Namespace wrote: http://dlang.org/operatoroverloading.html#function-call Like this: module main; import std.stdio; class F { int opCall(int value) { return value * 2; } } void main(string[] args) { auto

Re: ICE?

2015-05-17 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: Is this error an ICE? I think so, because I see the internal filename, but I'm not sure. Error: e2ir: cannot cast malloc(length * 8u) of type void* to type char[] Have you got a code sample to reproduce this?

Re: What wrong?

2015-05-15 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 15 May 2015 at 07:51:29 UTC, thedeemon wrote: On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote: Simple code: http://pastebin.com/raw.php?i=7jVeMFXQ What I'm doing wrong? Try using class instead of struct. Last time I played with std.concurrency it used Variants to

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 06:37:44 UTC, ketmar wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such abomination should: 1. be forbidden,

Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-28 Thread Gary Willoughby via Digitalmars-d-learn
After reading the following thread: http://forum.dlang.org/thread/nczgumcdfystcjqyb...@forum.dlang.org I wondered if it was possible to write a classic fizzbuzz[1] example using a UFCS chain? I've tried and failed. [1]: http://en.wikipedia.org/wiki/Fizz_buzz

Re: Building website from git master, why does it checkout DMD v2.066.1 and die?

2015-04-20 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 19 April 2015 at 21:26:11 UTC, Vladimir Panteleev wrote: On Sunday, 19 April 2015 at 16:20:23 UTC, Gary Willoughby wrote: If i pass the correct information on the command line it gets past the library errors but now shows linker errors. I'm not seeing the compilation errors when

Re: ctags

2015-04-20 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 20 April 2015 at 18:14:34 UTC, Robert M. Münch wrote: Hi, is there anything for D that supports generating tags files like ctags does for C etc. ? I and some others have merged D support into the following fork of exuberant-ctags: https://github.com/fishman/ctags This is the

Re: Linker errors building tools from git master

2015-04-19 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 18 April 2015 at 17:15:40 UTC, Gary Willoughby wrote: Any ideas why i'm getting these linker errors? This seems to be because i wasn't correctly specifying the newly generated phobos lib in the dmd.conf.

Re: Building website from git master, why does it checkout DMD v2.066.1 and die?

2015-04-19 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 19 April 2015 at 16:21:45 UTC, Jacob Carlborg wrote: Do you have libcurl installed? Yeah and i've looked at the build scripts etc, and can't see anything obviously wrong.

Re: Building website from git master, why does it checkout DMD v2.066.1 and die?

2015-04-19 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 19 April 2015 at 09:06:58 UTC, Jacob Carlborg wrote: On 2015-04-19 10:56, Jacob Carlborg wrote: The makefile isn't updated, see [1]. Trying adding STABLE_DMD_VER=2.067.0 to the command you're running. Pull request: https://github.com/D-Programming-Language/dlang.org/pull/968 If

Linker errors building tools from git master

2015-04-18 Thread Gary Willoughby via Digitalmars-d-learn
I've cloned the main repositories and i'm trying to get everything building successfully. DMD, druntime and phobos all built without a hitch. When building the tools however i'm getting a lot of warnings from new compiler features (which is to be expected i guess) but i'm also getting linker

Building website from git master, why does it checkout DMD v2.066.1 and die?

2015-04-18 Thread Gary Willoughby via Digitalmars-d-learn
I'm trying to build the website from git master and i'm getting some errors. Here is the last part of the output: ... touch ../dub-0.9.22/.cloned mkdir -p /tmp/.stable_dmd-2.066.1 TMPFILE=$(mktemp deleteme.) curl -fsSL http://downloads.dlang.org/releases/2014/dmd.2.066.1.linux.zip

Re: Mixin and map

2015-04-05 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 5 April 2015 at 21:23:14 UTC, Dennis Ritchie wrote: Hi, Can you please tell how to make map worked correctly. I want to program published [2, 3, 4, 5, 6]. - import std.stdio; import std.algorithm; string print(string s) { return `writeln(` ~ s ~ `);`; } void main() {

Re: Issue with free() for linked list implementation

2015-04-03 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 3 April 2015 at 22:08:52 UTC, Kitt wrote: Thanks for the help =) I guess I've been in C# land at work for way too long now, my low level C skills are evaporating! I've written a straight forward linked list implementation here:

Re: Accessing a field of a containing class from within a nested class

2015-04-01 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 1 April 2015 at 18:26:49 UTC, Charles Hixson wrote: Perhaps BTree needs to be a class? I made it a struct because I want it to definitely close properly when it goes out of scope. Maybe `scoped` can help: http://dlang.org/phobos/std_typecons.html#.scoped

Re: final methods by default

2015-03-20 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote: Why aren't methods of class final by default? See: http://forum.dlang.org/thread/lfqoan$5qq$1...@digitalmars.com

Re: How to generate a random string ...

2015-03-16 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 16 March 2015 at 13:33:55 UTC, Robert burner Schadek wrote: ... from all Unicode characters in an idiomatic D way? (std.interal.unicode_*) ``` T genUnicodeString(T)(size_t minChars, size_t maxChars) if(isSomeString!T) { ... } ``` I guess it depends on the encoding? Some

Re: Problem Instantiating a BinaryHeap with a Comparison Function the needs this

2015-02-19 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 19 February 2015 at 11:56:19 UTC, Nordlöw wrote: I can understand how to correctly define an instance of BinaryHeap in my class DijkstraWalker at https://github.com/nordlow/justd/blob/master/knet/traversal.d#L264 because the comparsion function can't ge access to the class

Re: Need help to understand how to work with tkd

2015-02-18 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 18 February 2015 at 08:19:25 UTC, Suliman wrote: Now I am trying to learn how to build GUI apps in D. But I have some troubles. Read the README file in the repository. Then fully read the documentation inside the `docs` folder. Then there is an example application in

Re: How to pass -rpath=$ORIGIN to the linker via dub?

2015-02-17 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 16 February 2015 at 23:49:31 UTC, 岩倉 澪 wrote: I'm looking to manage my current project with dub, but there is one problem that has been getting in my way. I want to use `-rpath=$ORIGIN`, which I can pass with `-L-rpath=\$ORIGIN` when directly invoking the compiler, but when putting

Re: The best way to compare floating point values.

2015-02-14 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 14 February 2015 at 09:37:05 UTC, Jack Applegame wrote: I wrote this function for comparing two floating point values: import std.math; import std.traits; bool isEqual(T)(T v1, T v2) if(isFloatingPoint!T) { return T.mant_dig - feqrel(v1, v2) 2; } What do you think about it?

Re: std.conv.to purity

2015-02-14 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 14 February 2015 at 12:24:51 UTC, ketmar wrote: On Sat, 14 Feb 2015 11:29:28 +, Jack Applegame wrote: why std.conv.to is not pure? string foo(real v) pure { return v.to!string; } // Error: pure function 'foo' cannot call impure function 'std.conv.to!string.to!(real).to'

Re: dmd-2.067.0-b1

2015-02-13 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:38:04 UTC, Dennis Ritchie wrote: This is a bug? import std.stdio; void main() { int a = 0; writeln( (a 10) ? a = 1 : a = 2 );// prints 2 writeln( (a 10) ? a = 1 : (a = 2) ); // prints 1 } Even C++ output: 1 1 Maybe a similar issue as

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-22 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 22 January 2015 at 11:23:49 UTC, Nordlöw wrote: What is the meaning of selectors such as `a[href]` used in doc.querySelectorAll(`a[href]`) ? Select all `a` tags that have a `href` attribute. You can also select using the attribute value too. For example get all the

Re: string concatenation with %s

2015-01-07 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 16:38:25 UTC, Suliman wrote: I need to construct complex SQL request, like: string sql = (INSERT INTO test.geomagnetic (`date`, `a_fredericksburg`, `fredericksburg`, `a_college`, `college`, `a_planetary`, `planetary`) VALUES ('%s', '%s', '%s', '%s', '%s',

Re: Compile for other OS's on Windows?

2015-01-05 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 5 January 2015 at 11:49:32 UTC, Bauss wrote: Is it possible to compile for other OS's on Windows using dmd? This is what's known as cross compiling and is not currently supported by DMD at this time.

Re: simple dub question - avoiding creating a vibed project

2015-01-05 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 5 January 2015 at 10:27:06 UTC, Laeeth Isharc wrote: Hi. I am building an example for hibernated (I put a main around the sample code extract from the website). How do I stop dub trying to build a vibed project? Here is my dub.json { name: ddbc example, description:

Re: Passing string literals to C

2015-01-01 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 11:19:36 UTC, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() {

Order of evaluation of post-increment operator

2014-12-28 Thread Gary Willoughby via Digitalmars-d-learn
I was just taking a look at the following poll[1] about the order of evaluation when using the post-increment operator. The following D snippet shows an example. import std.stdio; void main(string[] args) { auto foo = [0, 0]; int i = 0;

Re: [TkD] X11 Error(Possible bug?)

2014-12-27 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 26 December 2014 at 07:46:03 UTC, Jack wrote: On Friday, 26 December 2014 at 07:23:34 UTC, Rikki Cattermole wrote: On 26/12/2014 6:58 p.m., Jack wrote: Complete error code here: http://codepad.org/KcW7jhXl Apparently, there exists an incompatibility. Take note, I just listed tkd as

Re: Wrapping multiple extern (C) declarations in a template

2014-12-13 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 13 December 2014 at 16:34:42 UTC, aldanor wrote: I'm writing bindings to a rather big C library where the return values of almost all functions indicate the possibility of an error (exception). Assuming there's a C header, foo.h with functions f1, f2, etc, I want to have a

Re: Wrapping multiple extern (C) declarations in a template

2014-12-13 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 13 December 2014 at 19:03:42 UTC, aldanor wrote: Let's say there's a foo.d that contains raw bindings to foo.h (enums, structs, extern variables, function declarations, a whole load of stuff) -- everything but the functions is already fine but all functions need to be wrapped.

Re: How do i use std.functional.binaryFun?

2014-12-09 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 01:17:47 UTC, anonymous wrote: Looks like a compiler bug. Filed: https://issues.dlang.org/show_bug.cgi?id=13843

How do i use std.functional.binaryFun?

2014-12-08 Thread Gary Willoughby via Digitalmars-d-learn
How do i successfully use std.functional.binaryFun in the following example? import std.stdio; import std.functional; class Foo(T, alias greater = a b) if (is(typeof(binaryFun!(greater)(T.init, T.init)) == bool)) { private alias compare = binaryFun!(greater); public this()

Check type is a struct at compile time?

2014-12-05 Thread Gary Willoughby via Digitalmars-d-learn
How can i check that a type is a struct at compile time? I know i can test for a class like this: static if(is(T == class)) { ... } But how to do the same thing for a struct?

Re: Learning D for a non computer science background person : pre-requisite knowledge?

2014-12-02 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 2 December 2014 at 17:15:28 UTC, Mayuresh Kathe wrote: Okay, if that is the case, I'll dive into Mr. Alexandrescu's book as soon as I get my copy. No need to wait that long. I second H.S. Teoh's suggestion to recommend reading this book too: http://ddili.org/ders/d.en/intro.html

Re: [dub] Size of executable

2014-11-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was

Re: TKd handling of custom events

2014-11-20 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 19 November 2014 at 23:44:00 UTC, univacc wrote: Hello, I am using TKd to dray my linux/windows app which works very good! I would like to add a global Hotkey to my program via the Win32 API function RegisterGlobalHotkey. Is there a possibility to access Tk's event loop so

Re: How to use Linux message queues?

2014-11-15 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 15 November 2014 at 00:33:02 UTC, Neven wrote: On Friday, 14 November 2014 at 16:45:45 UTC, Sean Kelly wrote: Sounds like a module that should be in core.sys.linux. Care to submit a pull request? Ok, I've tried to make a module, though since I'm a D beginner (also a student who

Re: How to use Linux message queues?

2014-11-15 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 15 November 2014 at 00:33:02 UTC, Neven wrote: Ok, I've tried to make a module, though since I'm a D beginner (also a student who fiddles with D for Operating system classes) Incidentally, where are you studying? It would be nice to know where D is being taught.

Re: How to use Linux message queues?

2014-11-14 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 14 November 2014 at 16:45:45 UTC, Sean Kelly wrote: Sounds like a module that should be in core.sys.linux. Care to submit a pull request? Yes, these are usually added when someone requires them. Neven, if you're able, submitting a pull request to druntime of the complete module

Re: Live without debugger?

2014-11-09 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 9 November 2014 at 08:26:59 UTC, Suliman wrote: I know that a lot of people are using for programming tools like Sublime. I am one of them. But if for very simple code it's ok, how to write hard code? Do you often need debugger when you are writing code? For which tasks debugger

Re: Delegates and C function pointers

2014-11-08 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 8 November 2014 at 12:23:45 UTC, Nicolas Sicard wrote: I would like to register a D delegate to a C API that takes a function pointer as a callback and a void* pointer to pass data to this callback. My solution is in http://dpaste.dzfl.pl/7d9b504b4b965. Is this code correct? Is

Re: [SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 23:09:33 UTC, Jack wrote: So there must be an incompatibility with the video subsystem and tcl/tk. So it seems. Thank you very much for helping me. You were a big help. Sorry i can't do more. I'm the author of Tkd and would like to get to the bottom of it.

Re: scope exception do not rise

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 14:04:26 UTC, MadProgressor wrote: The scope(failure) is translated to a try catch after the satement you wann monitor. So put it before That shouldn't matter. See: http://dlang.org/exception-safe.html

<    1   2   3   >