Re: extended characterset output

2022-04-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 April 2022 at 15:06:41 UTC, Ali Çehreli wrote: On 4/8/22 02:51, anonymous wrote: > Weird, I got this strange feeling that this problem stemmed from the > compiler I'm using (GDC) Some distribution install an old gdc. What version is yours? Ali Not sure actually. I just did "apt

Re: extended characterset output

2022-04-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 April 2022 at 08:36:33 UTC, Ali Çehreli wrote: [snip] However, isControl() below won't work because isControl() only knows about the ASCII table. It would miss the unprintable characters above 127. [snip] This actuall works because I'm using std.uni.isControl() instead of

Re: extended characterset output

2022-04-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 April 2022 at 08:36:33 UTC, Ali Çehreli wrote: On 4/7/22 23:13, anonymous wrote: > What's the proper way to output all characters in the extended character > set? It is not easy to answer because there are a number of concepts here that may make it trivial or complicated. The

extended characterset output

2022-04-08 Thread anonymous via Digitalmars-d-learn
What's the proper way to output all characters in the extended character set? ```d void main() { foreach(char c; 0 .. 256) { write(isControl(c) ? '.' : c); } } ``` Expected output: ```

Re: Get pointer or reference of an element in Array(struct)

2017-12-08 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...] auto d2 = gallery[0]; auto d2 = [0];

What is this error message telling me?

2017-04-11 Thread Anonymous via Digitalmars-d-learn
I was watching a dconf presentation from last year and wanted to try this out: https://github.com/luismarques/parnas72. It doesn't compile / run as it is and the problem seems to be in the function below. import std.algorithm; import std.range; import std.uni; /// Performs [["foo", "bar"],

Re: how to mark an extern function @nogc?

2016-07-12 Thread anonymous via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:04:55 UTC, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) With the fundation, volunteers wont be highly motivated anymore. Fundations are real motivation-killers.

Re: Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
On Monday, 6 June 2016 at 02:21:03 UTC, docandrew wrote: On Sunday, 5 June 2016 at 21:26:56 UTC, Anonymous wrote: On Sunday, 5 June 2016 at 21:16:36 UTC, Andrej Mitrovic wrote: On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: [...] You can

Re: Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
On Sunday, 5 June 2016 at 21:16:36 UTC, Andrej Mitrovic wrote: On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: Should I report this as a dmd bug then? Not sure where / how to do that. You can report it here: https://issues.dlang.org I think I'l

Re: Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
On Sunday, 5 June 2016 at 20:16:54 UTC, Andrej Mitrovic wrote: On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: static Note[0] empty; Note[] getNotes(string id) { return (id in store) ? store[id] :

Re: Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
On Sunday, 5 June 2016 at 18:45:36 UTC, docandrew wrote: On Sunday, 5 June 2016 at 18:36:13 UTC, Anonymous wrote: On Sunday, 5 June 2016 at 18:30:25 UTC, Anonymous wrote: [...] Should have included: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights

Re: Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
On Sunday, 5 June 2016 at 18:30:25 UTC, Anonymous wrote: Why does the following give a linker error? If I change static Note[0] empty; to static Note[] empty;, all is well. Or if I leave it as Note[0] empty; and don't use it in getNotes, all is well. struct Note { string topic;

Linker error

2016-06-05 Thread Anonymous via Digitalmars-d-learn
Why does the following give a linker error? If I change static Note[0] empty; to static Note[] empty;, all is well. Or if I leave it as Note[0] empty; and don't use it in getNotes, all is well. struct Note { string topic; string content; } class NoteStore {

Re: How to return a const handle (view) to a mutable member of an agregate

2016-03-13 Thread anonymous via Digitalmars-d-learn
On Sunday, 13 March 2016 at 22:34:54 UTC, Chris Wright wrote: In theory, it can't be modified. As a practical matter, unions and casts will allow people to modify it. Saying that it *can't* be modified is slightly besides the point, yeah. It *must* not be modified. Casting away const and then

Re: How to return a const handle (view) to a mutable member of an agregate

2016-03-13 Thread anonymous via Digitalmars-d-learn
On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote: ref const(Array!Type) view(){} Unless the result is explicitly cast later it can't me modified. No, it can't be modified, period. Casting away const and then mutating is not allowed, it has undefined behavior.

Re: template mixins vs alias

2016-02-22 Thread anonymous via Digitalmars-d-learn
On Monday, 22 February 2016 at 13:35:10 UTC, Andrea Fontana wrote: Check this code: http://dpaste.dzfl.pl/fcf876acbbdc Structs A and B do the same things, in different way. Is there any difference/limitation between those? Andrea The mixin variant generates a method. That means, you can

Re: compilation issues (dmd, rdmd, ldc2)

2016-02-21 Thread anonymous via Digitalmars-d-learn
On 21.02.2016 22:51, kraxli wrote: On Sunday, 21 February 2016 at 21:35:55 UTC, anonymous wrote: [...] a) do it the linker way: `dmd -L-L~/.dub/packages/consoled-1.0.0/ -L-lconsoled ...`, or b) do it the dmd way: `dmd ~/.dub/packages/consoled-1.0.0/libconsoled.a ...`. b) works! :-) Many

Re: compilation issues (dmd, rdmd, ldc2)

2016-02-21 Thread anonymous via Digitalmars-d-learn
On Sunday, 21 February 2016 at 21:21:30 UTC, kraxli wrote: Thanks for coming back on that! The problem is the consoled-package which has the library: ~/.dub/packages/consoled-1.0.0/libconsoled.a So I link it (or aim to do it ;-) ) but dmd cannot find it: $ dmd

Re: compilation issues (dmd, rdmd, ldc2)

2016-02-21 Thread anonymous via Digitalmars-d-learn
On Sunday, 21 February 2016 at 20:04:34 UTC, kraxli wrote: What is going on here and what is the difference between dmd and rdmd? dmd compiles the modules that you specify on the command line. By default, it then links an executable from the generated object files. The linking can only work

Re: Confusion regarding struct lifecycle

2016-02-17 Thread anonymous via Digitalmars-d-learn
On 17.02.2016 17:36, Matt Elkins wrote: I tried this, and got the same issue. Actually, I was still able to reproduce the original reported issue as well, which leads me to believe either the bug was not actually fixed or (and this is more likely) I screwed something up with my install. Do I

Re: static array of structs clarification questions

2016-02-12 Thread anonymous via Digitalmars-d-learn
On 12.02.2016 22:08, WhatMeWorry wrote: question #1: The static array must contain the fat pointers to str variables. But where is the string data itself actually held: the stack? the heap? somewhere else? (does it vary depending on location or scope) Depends on how the string was created. You

Re: why mkdir can't create tree of dirs?

2016-02-09 Thread anonymous via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:20:59 UTC, Suliman wrote: It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar\baz I can only create D:\foo\bar http://dlang.org/phobos/std_file.html#.mkdirRecurse

Re: UFCS on Enum in Member Function

2016-02-09 Thread anonymous via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 21:05:50 UTC, jmh530 wrote: For instance, in the code below, I could use Baz but not Caz. It seems to work when I use the alternate version of Caz calling a non-member function. Bug? No bug; works as intended. UFCS can only be used with free functions, not

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 22:49, Matt Elkins wrote: From this non-reduced situation, does anything jump out? Am I missing something about struct lifetimes? This is the only place I instantiate a TileView. Looks weird. I presume this doesn't happen with simpler constructor parameters/arguments, like int

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 23:07, Márcio Martins wrote: The destructor you are seeing is from the assignment: m_tileView = TileView(...); This creates a temporary TileView, copies it to m_tileView, and then destroys it. I suppose you want to move it instead. You need to copy the handles from the temporary

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 23:49, Matt Elkins wrote: Oi. Yes, I can, but it is quite a lot of code even if you don't count that it is dependent on OpenGL, GLFW, and gl3n to run to this point. This is why I was disappointed that simpler reproducing cases weren't appearing. I should probably spend more time

Re: foreach seems to work with opIndex()

2016-02-06 Thread anonymous via Digitalmars-d-learn
On 06.02.2016 15:43, Tofu Ninja wrote: Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I just didnt really expect it

Re: DMD OSX / Segfault 11

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 03.02.2016 14:16, Robert M. Münch wrote: Well, it should of course be: BaseOperator: Value { } Still missing "class". I know I'm being pedantic, but if you're being sloppy here, how do I know that you're not being sloppy where it matters? Casting between class types that have an

Re: How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 04.02.2016 00:45, Enjoys Math wrote: On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: body { // is currently: return to!string(this.toHash()); } and is returning a base10 string, so how would I return a hex string so I can compare numbers displayed to the debugger

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 03.02.2016 16:34, Andrea Fontana wrote: void main() { enum first = very_very_long_function(10); writeln("First is ", first); auto second = very_very_long_function(12); writeln("Second is ", second); auto third = first; third += 1;

Re: const and immutable member variables in classes

2016-02-02 Thread anonymous via Digitalmars-d-learn
On 02.02.2016 23:48, Ali Çehreli wrote: struct S { const int c;// Makes S non-assignable immutable int i;// Makes S non-assignable } void main() { auto a = S(); auto b = S(); a = b; // Compilation ERROR } (That is the same issue in C++.)

Re: DMD OSX / Segfault 11

2016-02-02 Thread anonymous via Digitalmars-d-learn
On 02.02.2016 19:06, Robert M. Münch wrote: I have a very strange effect, I'm not sure what it is about: Value: {} WordV: Value { Value* get() {} } BaseOperator: Value : { } This isn't valid D code at all, which makes it unnecessarily hard to understand what you mean. Now comes the

Re: Switch with dynamic case

2016-02-02 Thread anonymous via Digitalmars-d-learn
On 02.02.2016 15:07, Daniel Kozak wrote: import std.stdio; import std.typetuple : TypeTuple; alias cs = TypeTuple!(0, 1, 2, 3); void main(string[] argv) { switch(argv.length) { default: writeln("Uknown number of args"); break; foreach(c; cs) {

Re: Declaring rvalue function arguments

2016-01-31 Thread anonymous via Digitalmars-d-learn
On 31.01.2016 18:21, Matt Elkins wrote: I know I can mark an argument ref to require lvalues, so I'm wondering whether there is an equivalent for rvalues; that is, is there a way to specify that an argument to a function MUST be an rvalue? For example, in C++ I can do this: [code] void foo(int

Re: Problem when calling toJSON()

2016-01-31 Thread anonymous via Digitalmars-d-learn
On 01.02.2016 01:29, Alex Herrmann wrote: This problem is solved! Sorry for not updating the question. It was actually a problem with me not iduping it, and the memory being reclaimed or something similar. I did also change to stdx.data.json (std_data_json on dub). You don't seem to be clear

Re: How do you initialize a class instance which has static storage within another class?

2016-01-30 Thread anonymous via Digitalmars-d-learn
On 30.01.2016 22:52, Enjoys Math wrote: class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level It works when you make b const/immutable: class A {static immutable B b = new B;} class B {} If you want/need b to be mutable, you can

Re: Error using templates: "cannot use template to add field to aggregate ''"

2016-01-25 Thread anonymous via Digitalmars-d-learn
On 25.01.2016 15:51, pineapple wrote: class unitvalue{ double coefficient; int[unit] exponents; unitvalue copy(){ unitvalue value = new unitvalue(); value.coefficient = this.coefficient; value.exponents = this.exponents.dup; return value;

Re: Templates, templates, templates...

2016-01-24 Thread anonymous via Digitalmars-d-learn
On 24.01.2016 10:02, Voitech wrote: I added base class for Rule -> BaseRule. But this class is just a shell without implementation. Is there any way to avoid this ? What's the problem with BaseRule not having any implementation? When the different Rule instantiations don't have any common

Re: core.thread.Thread.start is marked as "nothrow" but documentation says it throws

2016-01-23 Thread anonymous via Digitalmars-d-learn
On 23.01.2016 12:44, tcak wrote: https://dlang.org/phobos/core_thread.html#.Thread final nothrow Thread.start() Looking at the code, no "throw new ..." is seen, but the function "onThreadError" is called which has "throw" in it. Most weird thing is that "onThreadError" function is marked as

Re: Templates, templates, templates...

2016-01-23 Thread anonymous via Digitalmars-d-learn
On 23.01.2016 12:30, Voitech wrote: Ok so i want to hold different types in LogicRule maybe Algebraic implementation would do? private alias ControllTemplate(T) =Rule!(T,ControllFlag); private alias SymbolRule =ControllTemplate!(SymbolType); private alias StringRule

Re: D ASM. Program fails

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 21:34, Iakh wrote: This code returns 0 for any input v It seems to return 5 here: http://dpaste.dzfl.pl/85fb8e5c4b6b

Re: D ASM. Program fails

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 06:59, Iakh wrote: import std.stdio; import core.simd; int pmovmskb(inout byte16 v) { asm { movdqa XMM0, v; pmovmskb EAX, XMM0; ret; } } void main() { byte16 a = [-1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; auto i =

Re: `static` symbol needs to be `immutable` for compile-time access?

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 10:56, Shriramana Sharma wrote: Do all values which need to be readable at compile time need to be declared `immutable`? Yes, `static immutable` or `enum`. In C/C++ the `static` here is used to avoid the array being created every time the function is entered; in D too it does

Re: `static` symbol needs to be `immutable` for compile-time access?

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 15:33, Shriramana Sharma wrote: It would seem that in the case of arrays, the former is preferable to the latter, as per the para above this header: http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.variable, %20immutable The link doesn't work for me,

Re: writeln wipes contents of variables ?

2016-01-21 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 01:49, W.J. wrote: How can I identify those ranges, or, how can I tell if any particular range has value semantics ? I didn't read any of this in the manual - not that I could remember anyways. Generally you shouldn't. If you care about it either way, use .save or

Re: Unions and Structs

2016-01-18 Thread anonymous via Digitalmars-d-learn
On 18.01.2016 18:10, Russel Winder via Digitalmars-d-learn wrote: So this is an error? union flob { ulong data; struct thingy { uint data; uint bits; } thingy burble; }; because you cannot have a union field with a name that is

copying directories recursively

2016-01-17 Thread anonymous via Digitalmars-d-learn
TL;DR: Is there a simple way to copy directories recursively? My goal is to copy the directories ./src/dlang.org/{css,images,js} and their contents to ./ddo/{css,images,js}. Naively I tried this: void main() { import file = std.file; auto outputPath = "./ddo/"; foreach (dir;

Re: Functions that return type

2016-01-16 Thread anonymous via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } No. A function cannot return a type. A template can evaluate to a type, though:

Re: Index a parameter tuple with a run-time index

2016-01-15 Thread anonymous via Digitalmars-d-learn
On 15.01.2016 21:42, Nordlöw wrote: How do I index a function parameter tuple with a run-time index? With a switch and a static foreach: void f(A...)(size_t i, A a) { import std.stdio: writeln; switch_: switch (i) { foreach (iT, T; A) { case iT:

Re: How to declare an alias to a function literal type

2016-01-12 Thread anonymous via Digitalmars-d-learn
On 12.01.2016 16:41, ParticlePeter wrote: // alias MF = void function( int i ); // not working // alias void function( int i ) MF; // not working These are both fine. The first one is the preferred style. MF myFunc; myFunc = MF { myCode }; This line doesn't work. Function literals don't

Re: How to declare an alias to a function literal type

2016-01-12 Thread anonymous via Digitalmars-d-learn
On 12.01.2016 17:55, ParticlePeter wrote: When I pass a parameter to otherFunc I use this syntax for an anonymous function parameter: otherFunc( void function( ref int p1, float p2, ubyte p3 ) { myCode; } ); You don't. That's not valid code. You can be using this: otherFunc( function void (

Re: [Dlang] Delegate Syntax Question

2016-01-10 Thread anonymous via Digitalmars-d-learn
On 10.01.2016 15:32, Jack wrote: // class Foo() Those parentheses make this a (zero parameter) class template. I suppose you just want a plain class. Drop them then. { void bar() { writeln("Hello World"); } } class Bar() ditto { void

Re: Nothrow front() when not empty()

2016-01-06 Thread anonymous via Digitalmars-d-learn
On 06.01.2016 14:52, Nordlöw wrote: At https://github.com/D-Programming-Language/phobos/pull/3752 it would be nice if return !haystack.empty && haystack.front.unaryFun!pred was made nothrow. Is this possible somehow? try return !haystack.empty && pred(haystack.front); catch

Re: About Immutable struct members and arrays.

2016-01-06 Thread anonymous via Digitalmars-d-learn
On 06.01.2016 23:04, Jack Applegame wrote: import std.algorithm; struct Bar { const int a; int b; } void main() { Bar[1] arr; Bar bar = Bar(1, 2); bar[0].b = 4; Assuming you meant `arr[0].b = 4;`. Just overwriting the mutable part of bar[0] is ok, of course.

Re: to!double different from cast(double)

2016-01-04 Thread anonymous via Digitalmars-d-learn
On 04.01.2016 09:22, Ali Çehreli wrote: void main() { const l = long.max; assert(l != l.to!double); // passes assert(l != cast(double)l);// FAILS } Is there a good explanation for this difference? I would expect both expressions to be compiled the same way. (I am aware

Re: Call C function - Access violation

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 21:32, TheDGuy wrote: If i type: gcc -c -otest.c.o the 'test.c.o' file is generated but if i type: dmd main.d test.c.o i get: 'Error: unrecognized file extension o'? You're probably on Windows then? dmd doesn't recognize the .o extension on Windows, use .obj instead.

Re: Call C function - Access violation

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 22:37, TheDGuy wrote: If i rename "test.o" to "test.obj" i get: 'Error: Module or Dictionary corrupt' My guess is, that means that dmd can't handle the object file format that gcc produces. Disclaimer: I don't know much about object formats, gcc, and Windows. I may be

Re: Call C function - Access violation

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 14:12, anonymous wrote: You shouldn't get a segfault, though. You should get some compile/link error. Are you compiling the right files? Can the segfault be from something other than your program? Oh, I see what's probably happening: You compile the D program, but you don't

Re: Call C function - Access violation

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 14:01, TheDGuy wrote: Okay, i think this C code should work (checked with cpp.sh): #import char* write(char* text){ return text; } int main(void){ return 0; } Uh, no. 1) In C it's include, not import. 2) Now you have two main functions, that can't work. You

Re: Repeated struct definitions for graph data structures and in/out naming conflict in C library

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 14:30, data pulverizer wrote: I am trying to access functionality in the glpk C library using extern(C). It has graph structs in its header file that are specified in an odd recurring manner that I cannot reproduce in D: I don't see what's odd about this. What exactly are your

Re: Call C function - Access violation

2016-01-03 Thread anonymous via Digitalmars-d-learn
On 03.01.2016 13:30, TheDGuy wrote: I get an access violation with this code: extern(C) char* write(char* text); void main(string[] args){ char[] text = "Hello World".dup; //.dup converts string to char[] text ~= '\0'; //append char* result = write(text.ptr); //you need .ptr

Re: Deducing a template argument from an aliased parameter

2016-01-01 Thread anonymous via Digitalmars-d-learn
On 31.12.2015 23:37, rcorre wrote: struct Vector(T, int N) { } alias Vector2(T) = Vector!(T, 2); void fun1(T)(Vector!(T, 2) vec) { } void fun2(T)(Vector2!T vec) { } unittest { fun1(Vector!(float, 2).init); fun2(Vector!(float, 2).init); } Why can fun1 deduce `T`, but fun2 can't?

Re: regex - match/matchAll and bmatch - different output

2016-01-01 Thread anonymous via Digitalmars-d-learn
On 30.12.2015 12:06, Ivan Kazmenko wrote: import std.regex, std.stdio; void main () { writeln (bmatch ("abab", r"(..).*\1")); // [["abab", "ab"]] writeln (match("abab", r"(..).*\1")); // [["abab", "ab"]] writeln (matchAll ("abab", r"(..).*\1")); // [["abab", "ab"]]

Re: DMD -L Flag, maybe a bug?

2015-12-26 Thread anonymous via Digitalmars-d-learn
On 26.12.2015 02:04, Bubbasaur wrote: On Friday, 25 December 2015 at 23:45:42 UTC, anonymous wrote: It's almost like the example in the URL you showed: dmd test.d -LC:/gtkd/src/build/GtkD.lib Note that in the docs I linked it's `dmd hello.d -L+gtkd.lib` with a plus sign. I'm not sure if it's

Re: Understand typeof trick

2015-12-25 Thread anonymous via Digitalmars-d-learn
On 25.12.2015 13:10, Joakim Brännström wrote: In http://forum.dlang.org/post/ojawnpggfaxevqpmr...@forum.dlang.org Adam uses findSkip as an example and especially points out the "D idiom with is/typeof". I'm not quite sure I understand it correctly. Please correct me if I have misunderstood

Re: DMD -L Flag, maybe a bug?

2015-12-25 Thread anonymous via Digitalmars-d-learn
On 25.12.2015 15:40, Bubbasaur wrote: But at least on Windows, you need to put a space between -L and the PATH. Which It's weird, since with "-I" flag you don't need any space. I don't think that's right. Unless something awful is going in Windows dmd, that should be processed as two separate

Re: DMD -L Flag, maybe a bug?

2015-12-25 Thread anonymous via Digitalmars-d-learn
On 25.12.2015 19:32, Bubbasaur wrote: On Friday, 25 December 2015 at 15:06:27 UTC, anonymous wrote: In fact it works without the "-L". Which makes me wonder if I was using it wrongly? I'm convinced that putting a space between "-L" and its argument is nonsense. The "-L" part just means "pass

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread anonymous via Digitalmars-d-learn
On 21.12.2015 21:20, Steven Schveighoffer wrote: This seems like an incorrect feature then. Why wouldn't I want S to be treated like any other const(char)*? Seems like it's explicitly saying "treat this like a const(char)*" To my understanding, `alias this` means "is implicitly convertible to

Re: What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread anonymous via Digitalmars-d-learn
On 21.12.2015 17:02, Shriramana Sharma wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L878 The `static if` condition here says if something is a pointer and if it is implicitly convertible to const(char)*. The isPointer! part seems superfluous. Is there something

Re: Problems with string literals and etc.c.odbc.sql functions

2015-12-19 Thread anonymous via Digitalmars-d-learn
On 19.12.2015 14:20, Marc Schütz wrote: As this is going to be passed to a C function, it would need to be zero-terminated. `.dup` doesn't do this, he'd have to use `std.string.toStringz` instead. However, that function returns a `immutable(char)*`, which would have to be cast again :-( Ouch,

Re: Problems with string literals and etc.c.odbc.sql functions

2015-12-18 Thread anonymous via Digitalmars-d-learn
On 18.12.2015 23:14, Fer22f wrote: By the use of this tutorial (http://www.easysoft.com/developer/languages/c/odbc_tutorial.html), I thought it would be very straightforward to use etc.c.odbc.sqlext and etc.c.odbc.sql to create a simple odbc application. But as soon as I started, I noticed a

Re: Problems with string literals and etc.c.odbc.sql functions

2015-12-18 Thread anonymous via Digitalmars-d-learn
On 19.12.2015 01:06, Fer22f wrote: Documentation on casts say: Casting a pointer type to and from a class type is done as a type paint (i.e. a reinterpret cast). That sentence doesn't apply. string is not a class, it's an alias for immutable(char)[], i.e. it's an array. Reinterpretation

Re: D float types operations vs C++ ones

2015-12-17 Thread anonymous via Digitalmars-d-learn
On 17.12.2015 12:50, drug wrote: I have two implementation of the same algorithm - D and C++ (that is port of D version). I assume that running these implementations on the same data should give the same results from both. But with some data the results differ (5th decimal digit after point).

Re: isBidirectionalRange fails for unknown reasons

2015-12-16 Thread anonymous via Digitalmars-d-learn
On 16.12.2015 21:43, Jack Stouffer wrote: I'm trying to add a ReferenceBidirectionalRange range type to std.internal.test.dummyrange so I can test some range code I'm writing, but I've hit a wall and I'm not sure why. For some reason, the isBidirectionalRange check fails even though back and

Re: How to check if result of request to DB is empty?

2015-12-12 Thread anonymous via Digitalmars-d-learn
On 12.12.2015 08:44, Suliman wrote: string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic parts. Imagine what happens when the user enters an apostrophe in

Re: How to check if result of request to DB is empty?

2015-12-11 Thread anonymous via Digitalmars-d-learn
On 11.12.2015 22:05, Suliman wrote: I am using https://github.com/buggins/ddbc string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic parts. Imagine what

Re: The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)

2015-12-07 Thread anonymous via Digitalmars-d-learn
On 07.12.2015 21:56, John Carter wrote: So whilst attempt to convert from a hex string (without the 0x) to int I bumped into the @@@BUG@@@ the size of China https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270 Is there a bugzilla issue number tracking this?

Re: Comparison operator overloading

2015-12-07 Thread Anonymous via Digitalmars-d-learn
On Monday, 7 December 2015 at 17:18:20 UTC, Dominikus Dittes Scherkl wrote: Hmm. But it works just fine! It overloads also the special floatingpoint operators <> !<> !<= and so on. Those are deprecated: http://dlang.org/deprecate.html#Floating%20point%20NCEG%20operators And how else could I

Re: benchmark on binary trees

2015-12-05 Thread anonymous via Digitalmars-d-learn
On 05.12.2015 01:40, Alex wrote: found and tried out the -vgc option... Is there a way to deactivate the GC, if it stands in way? You can call core.memory.GC.disable to disable automatic collections. .enable to turn them on again. http://dlang.org/phobos/core_memory.html#.GC Yes, I

Re: using parse with string slice

2015-12-05 Thread anonymous via Digitalmars-d-learn
On 05.12.2015 22:59, Quentin Ladeveze wrote: --- import std.conv; string s = "1B2A"; int value = parse!int(s[0..2], 16); //template std.conv.parse cannot deduce function from argument types !(int)(string, int) --- Does someone have an idea of why it happens ? The version of parse that is used

Re: benchmark on binary trees

2015-12-04 Thread anonymous via Digitalmars-d-learn
On 04.12.2015 15:06, Alex wrote: 3. The compilation was done by: dmd -O -release -boundscheck=off [filename.d] Is there anything else to improve performance significantly? You forgot -inline. By the way, I'm not a fan of using -boundscheck=off like a general optimization flag. It undermines

Re: benchmark on binary trees

2015-12-04 Thread anonymous via Digitalmars-d-learn
On 04.12.2015 21:30, Alex wrote: Yes, I missed this, sorry. The main part of the question was probably about the class and struct difference. I thought handling with structs and pointers would be faster then with classes. When you use a struct directly, without going through a pointer, that

Re: benchmark on binary trees

2015-12-04 Thread anonymous via Digitalmars-d-learn
On 04.12.2015 15:06, Alex wrote: 1. I wrote the C++ inspired version after the C# inspired, hoping it would be faster. This was not the case. Why? [...] Why did you expect the C++ inspired version to be faster? Just because the original was written in C++? From a quick skim the two versions

Re: DDOC adds emphasis on symbols, so how to use $(LINK a) properly?

2015-12-01 Thread anonymous via Digitalmars-d-learn
On 01.12.2015 16:15, kraybit wrote: /** * Also see $(LINK mylib.image.pixel.html) */ module mylib; ... This will generate a link, but the href will be "mylib.image.pixel.html", which won't work in my browser at least (Chromium). This can be fixed with: $(LINK

Re: DDOC adds emphasis on symbols, so how to use $(LINK a) properly?

2015-12-01 Thread anonymous via Digitalmars-d-learn
On 01.12.2015 16:52, kraybit wrote: Hm, I see, so it's contextual? Would 'pixel' then be emphasized if I'm in the documentation of void pixel()? Yes and yes. I just get the feeling I need to think before using LINK. I'd like to not think, too much. It's a clever feature for sure. Maybe

Re: having problem with `std.algorithm.each`

2015-11-30 Thread anonymous via Digitalmars-d-learn
On 30.11.2015 11:50, visitor wrote: though i don"t understand why it fails silently ?? ref2491's original code is valid, but doesn't have the intended meaning. `e => {foo(e);}` is the same as `(e) {return () {foo(e);};}`, i.e. a (unary) function that returns a (nullary) delegate. Calling it

Re: DateTime.opBinary

2015-11-29 Thread anonymous via Digitalmars-d-learn
On 30.11.2015 00:25, bachmeier wrote: I was just reading through the documentation for std.datetime. DateTime.opBinary looks pretty interesting: http://dlang.org/phobos/std_datetime.html#.DateTime.opBinary Does anyone know how to use it? You certainly can't learn anything from the

Re: Can't understand how to do server response with vibed

2015-11-28 Thread anonymous via Digitalmars-d-learn
On 28.11.2015 19:51, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } Error: no property 'writeJsonBody' for type 'vibe.http.server.HTTPServerRequest' But this method are present in

Re: Can't understand how to do server response with vibed

2015-11-28 Thread anonymous via Digitalmars-d-learn
On 28.11.2015 19:46, Suliman wrote: And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json; charset=UF-8", bool

Re: EnumMemberNames

2015-11-27 Thread anonymous via Digitalmars-d-learn
On 27.11.2015 15:05, drug wrote: I need to get names of enum members, is it possible? EnumMembers returns the members itself, i.e. ``` enum Sqrts : real { one = 1, two = 1.41421, three = 1.73205, } pragma(msg, [EnumMembers!Sqrts]); ``` returns

Re: switch with enum

2015-11-25 Thread anonymous via Digitalmars-d-learn
On 25.11.2015 21:06, Meta wrote: ...Which doesn't work because it won't compile without a default case. Is this a recent change? I don't remember D doing this before. Use `final switch`. Ordinary `switch`es need an explicit default case. `final switch`es have to cover all possibilities

Re: How to use D parallel functions/library

2015-11-24 Thread anonymous via Digitalmars-d-learn
On 24.11.2015 19:49, Bishop120 wrote: I figured this would be a simple parallel foreach function with an iota range of sizeX and just making int X declared inside the function so that I didnt have to worry about shared variable but I cant get around the alive++ reduction and I dont understand

Re: RAII trouble

2015-11-20 Thread anonymous via Digitalmars-d-learn
On 20.11.2015 23:56, Spacen Jasset wrote: The ideal would be to have a struct that can be placed inside a function scope, or perhaps as a module global variable. Why does Ft_Init_FreeType have to be read at compile time? text.d(143,15): Error: static variable FT_Init_FreeType cannot be read at

Re: char[] == null

2015-11-18 Thread anonymous via Digitalmars-d-learn
On 19.11.2015 06:18, Chris Wright wrote: Just for fun, is an array ever not equal to itself? Yes, when it contains an element that's not equal to itself, e.g. NaN.

Re: char[] == null

2015-11-18 Thread anonymous via Digitalmars-d-learn
On 18.11.2015 22:02, rsw0x wrote: slices aren't arrays http://dlang.org/d-array-article.html The language reference/specification [1] uses the term "dynamic array" for T[] types. Let's not enforce a slang that's different from that. [1] http://dlang.org/arrays.html

Re: Filtering a tuple of containers with indices

2015-11-17 Thread anonymous via Digitalmars-d-learn
On 17.11.2015 15:32, maik klein wrote: template tupIndexToRange(alias Tup, Indices...){ [snip] I don't quite understand how that code is supposed to work. Maybe there's just some detail missing, but it could also be that your approach can't work. This is roughly what I want to achieve

Re: Filtering a tuple of containers with indices

2015-11-17 Thread anonymous via Digitalmars-d-learn
On 17.11.2015 20:46, maik klein wrote: .selectFromTuple!(0, 1).expand Does this result in a copy? I avoided doing it like this because I was worried that I would copy every array. But I also don't fully understand when D will copy. Yes and no. It copies the Array structs, but it does not copy

Re: std.conv.to!string(array), strange compile error

2015-11-14 Thread anonymous via Digitalmars-d-learn
On 14.11.2015 15:17, Relja wrote: - std.conv.to!string() works on a static array, when called directly on the array object, but gives the compile error when called on the returning object from a function. [...] void main() { getFloat3().to!string; // does not compile (new

Re: std.conv.to!string(array), strange compile error

2015-11-14 Thread anonymous via Digitalmars-d-learn
On 14.11.2015 15:40, Relja wrote: float[3] array; array.to!string; // compiles Alright, full test case: import std.conv; float[3] getFloat3() { return [1, 2, 3]; } void main() { getFloat3().to!string; // does not compile float[3] a; a.to!string; // compiles }

Re: Am I using std.encoding correctly?

2015-11-14 Thread anonymous via Digitalmars-d-learn
On 14.11.2015 15:55, Charles wrote: I know there's safeDecode, but I'm also fairly confident that all strings can decode safely, already, and if it isn't I'd want an exception thrown from it. Documentation [1] says "The input to this function MUST be validly encoded." It says nothing about an

  1   2   3   4   5   6   >