Re: Scope of D packages

2015-12-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 December 2015 at 00:46:12 UTC, cym13 wrote: To be exact it doesn't need the sources, it needs the function signatures and type definitions so the equivalent of C header files. If you don't want to share the full sources with your library you can generate those header files autom

Re: Set color to a single point in Cairo

2015-12-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 December 2015 at 14:16:23 UTC, TheDGuy wrote: is it possible to set the color of a single pixel with Cairo? Not like you would do with a classic canvas (2d grid), because colors are applied with `cairo_fill()` and `cairo_stroke()` on a particular path. but you can define a p

Re: Can't debug my solution

2015-12-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 20 December 2015 at 01:29:59 UTC, Israel wrote: On Saturday, 19 December 2015 at 20:52:41 UTC, Matheus Reis wrote: Hello, people! I'm Matheus, a 20 y/o game developer who wants to get started with D. It has really caught my attention, and I've been playing with it for some hours no

Re: function without "this" cannot be const?

2015-12-20 Thread Basile B. via Digitalmars-d-learn
On Monday, 21 December 2015 at 02:03:14 UTC, Shriramana Sharma wrote: I'm trying to interface to a C function: extern(C) const char * textAttrN(const char * specString, size_t n); and getting the error: Error: function .textAttrN without 'this' cannot be const Please advise as to what I'm d

Re: Set color to a single point in Cairo

2015-12-21 Thread Basile B. via Digitalmars-d-learn
On Sunday, 20 December 2015 at 11:16:06 UTC, TheDGuy wrote: On Sunday, 20 December 2015 at 01:17:50 UTC, Basile B. wrote: On Saturday, 19 December 2015 at 14:16:23 UTC, TheDGuy wrote: is it possible to set the color of a single pixel with Cairo? Not like you would do with a classic canvas (2d

Re: Lots of D code

2015-12-22 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 00:59:53 UTC, steven kladitis wrote: I have 843 programs written in D. [...] All of the programs are from RosettaCode.org. The script to compile them generates a log file and you will see a few that the linker just stops No idea why. A few have 64K link e

Re: Multiple selective imports on one line

2015-12-23 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 19:34:26 UTC, earthfront wrote: On Wednesday, 23 December 2015 at 11:00:19 UTC, Jakob Ovrum wrote: [...] My goal is to import several symbols from different modules on one line. I'm trying to figure out if it's possible or not. It makes the code more concise

Re: Graphics/font/platform backends with common interfaces?

2015-12-23 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 20:52:05 UTC, Adam D. Ruppe wrote: On Wednesday, 23 December 2015 at 20:49:21 UTC, Taylor Hillegeist wrote: | GRAPICS LIB | +---+---+---+ <- what is this interface |SDL|GDI|OPENGL.| +---+---+---+ SDL, GDI, and OpenGL *are* graphics libs so it see

Re: Graphics/font/platform backends with common interfaces?

2015-12-23 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 21:12:11 UTC, Taylor Hillegeist wrote: On Wednesday, 23 December 2015 at 21:07:12 UTC, Basile B. wrote: [...] Thanks for letting me know! So is what your saying is that an common interface is not possible or practical or perhaps useful? It's possible but it

Re: Graphics/font/platform backends with common interfaces?

2015-12-23 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 21:19:14 UTC, Taylor Hillegeist wrote: On Wednesday, 23 December 2015 at 21:12:11 UTC, Taylor Hillegeist wrote: On Wednesday, 23 December 2015 at 21:07:12 UTC, Basile B. wrote: [...] Thanks for letting me know! So is what your saying is that an common interf

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } IDK but usually the const storage class is used for narrow strings because it allows to pass either `ch

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 04:54:07 UTC, Basile B. wrote: it allows to pass either `char[]` or `string[]`: I meant "char[]` or `string", string without square brackets of course...

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 05:29:44 UTC, riki wrote: On Sunday, 27 December 2015 at 04:54:07 UTC, Basile B. wrote: On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // err

are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
While working on a framework, I've found that Multiple Return Values (MRV) are clearly an optimization. I'de like to write a small D blog post about this but I don't know If it's clever enough or if it's a well know fact. My base D material is this: --- #!runnable-flags: -O -boundscheck=off -

Re: are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
I mean it's maybe "just" a special case of RVO, since tuples are processed as structs ?

Re: are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 December 2015 at 12:40:09 UTC, Basile B. wrote: I mean it's maybe "just" a special case of RVO, since tuples are processed as structs ? Also in the second version the stack size is modified by 78 bytes. Not when using MRV.

Re: Multiple selective imports on one line

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 December 2015 at 14:16:36 UTC, Basile B. wrote: On Monday, 28 December 2015 at 14:09:30 UTC, Joakim wrote: I wish dfmt could do this for us, so that you develop with all the modules imported at the top, then run dfmt and it scopes all the imports and adds the selective import of s

Re: Multiple selective imports on one line

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 December 2015 at 14:09:30 UTC, Joakim wrote: I wish dfmt could do this for us, so that you develop with all the modules imported at the top, then run dfmt and it scopes all the imports and adds the selective import of symbols. I've been thinking about implementing a tool to do th

Re: Lots of D code

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 00:59:53 UTC, steven kladitis wrote: I have 843 programs written in D. 805 actually create an 32 bit exe in windows 10. I am running the latest D. Some just start to link and the linker disappears. Some just have issues I am not able figure out. I can attach

Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote: On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote: On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote: Any idea what i am doing wrong? https://www.youtube.com/watch?v=j_VCa-5VeP8 You could post the code also, personnaly I'

Re: GTKD Cairo get pixel color

2015-12-30 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote: Hello, is there any way to get the pixel color of a single pixel by x and y coordinates of a context? render to a png back buffer. see cairo_image_surface_create_for_data then you'll be able to access the data and, at the same t

Re: GTKD Cairo get pixel color

2016-01-01 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote: On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote: Hello, is there any way to get the pixel color of a single pixel by x and y coordinates of a context? render to a png back buffer. see cairo_image_surface_create_f

Re: Size of Compiled Program

2016-01-04 Thread Basile B. via Digitalmars-d-learn
On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby, calculating the first n prime numbers, I realized, that for small n Ruby may be faster, than compiling and executing with D. But for n = 1,000,000 D outperforms Ruby by a

Re: GTKD Cairo get pixel color

2016-01-04 Thread Basile B. via Digitalmars-d-learn
On Friday, 1 January 2016 at 22:00:04 UTC, TheDGuy wrote: On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote: On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote: On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote: Hello, is there any way to get the pixel color

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 15:04:57 UTC, TheDGuy wrote: But i get "only one index allowed to index char". So it looks like there is no 2D array but just a char. If i try like this: The data is just a contiguous memory area. You have to implement your own opIndexAssign()/opIndex() to write/

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 16:25:01 UTC, TheDGuy wrote: But how do i know which line or column my pixel is in? - study D operator overloading, I've given you the solution. And what is 't' in 'opIndexAssign'? - t is what you want to assign. It can be an uint or maybe a float[4]. Look at my

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 17:16:10 UTC, TheDGuy wrote: On Tuesday, 5 January 2016 at 16:43:00 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 16:25:01 UTC, TheDGuy wrote: But how do i know which line or column my pixel is in? - study D operator overloading, I've given you the solution.

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 17:37:04 UTC, TheDGuy wrote: On Tuesday, 5 January 2016 at 17:34:06 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 17:16:10 UTC, TheDGuy wrote: On Tuesday, 5 January 2016 at 16:43:00 UTC, Basile B. wrote: [...] Okay, but what is this? "import iz.memory, iz

Re: Lots of D code

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 00:59:53 UTC, steven kladitis wrote: I have 843 programs written in D. 805 actually create an 32 bit exe in windows 10. I am running the latest D. Some just start to link and the linker disappears. Some just have issues I am not able figure out. I can attach

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 17:39:41 UTC, Basile B. wrote: IDK, except D I only speek/talk Object Pascal (FPC/Delphi). "I didn't know, apart D, I only speak/talk Object Pascal (FPC/Delphi)." Was what I meant. ^^

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 18:19:08 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 17:39:41 UTC, Basile B. wrote: IDK, except D I only speek/talk Object Pascal (FPC/Delphi). "I didn't know, apart D, I only speak/talk Object Pascal (FPC/Delphi)." Was what I meant. ^^ https://www.you

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 19:13:35 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 18:19:08 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 17:39:41 UTC, Basile B. wrote: IDK, except D I only speek/talk Object Pascal (FPC/Delphi). "I didn't know, apart D, I only speak/talk Object

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 19:47:02 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 19:13:35 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 18:19:08 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 17:39:41 UTC, Basile B. wrote: IDK, except D I only speek/talk Object Pascal (FPC

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 21:24:51 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 January 2016 at 21:01:55 UTC, Basile B. wrote: Awww... I'm so sorry. https://youtu.be/uyMUck2RRjw du bist normal oder idiot ? https://www.youtube.com/watch?v=nGLwBCMSXys

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 22:08:52 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 January 2016 at 22:02:47 UTC, Basile B. wrote: du bist normal oder idiot ? https://youtu.be/7kjTXMecCrM Ding dong! https://en.wikipedia.org/wiki/Turing_Award Si tu crois que tu es un génie, il y a de forte

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 22:40:22 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 22:08:52 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 January 2016 at 22:02:47 UTC, Basile B. wrote: du bist normal oder idiot ? https://youtu.be/7kjTXMecCrM Ding dong! https://en.wikipedia.org/wiki

Re: Variable below zero but if statement doesn't grab?

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote: On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote: On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote: On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote: On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Re: GTKD Cairo get pixel color

2016-01-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 23:36:16 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 January 2016 at 23:26:12 UTC, Basile B. wrote: access to pix is easy... This is the learn forum. Maybe one should be able to figure it out without asking, but there is nothing wrong with asking in depth on t

Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread Basile B. via Digitalmars-d-learn
On Thursday, 7 January 2016 at 21:00:06 UTC, zabruk70 wrote: Hello. In modern phobos ver 2.069.1 exists template hexString https://dlang.org/phobos/std_conv.html#.hexString to convert hex string to bytes. It works in compile time only. But what if i need it in run time? Is the answer in this t

Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread Basile B. via Digitalmars-d-learn
On Thursday, 7 January 2016 at 21:00:06 UTC, zabruk70 wrote: Hello. In modern phobos ver 2.069.1 exists template hexString https://dlang.org/phobos/std_conv.html#.hexString to convert hex string to bytes. It works in compile time only. But what if i need it in run time? Is the answer in this t

Re: version in enum

2016-01-09 Thread Basile B. via Digitalmars-d-learn
On Saturday, 9 January 2016 at 12:43:32 UTC, Øivind wrote: Hi, Why doesn't this work? Seems like it should: enum { A = 1, version(xx) { B = 2 } } It's not allowed in the grammar but I agree with you, it could be useful. Recent example where it could:

Re: Variable below zero but if statement doesn't grab?

2016-01-15 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 23:52:05 UTC, Basile B. wrote: On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote: On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote: On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote: On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

Fuck the brits

2016-01-15 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 January 2016 at 22:16:09 UTC, Basile B. wrote: On Tuesday, 5 January 2016 at 23:52:05 UTC, Basile B. wrote: On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote: On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote: On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wro

Re: how to allocate class without gc?

2016-01-26 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? This is more or less the same answer as you've get previously except that I don't use emplace

Re: how to allocate class without gc?

2016-01-28 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 22:39:54 UTC, Igor wrote: But doesn't this ultimately defeat the purpose of having manual memory management if one has to add it to the GC to be scanned? You can make the LOC related to the GC optional with an additional bool template parameter and a static if,

Re: is(some template instantiation) is true, but the actual instantiation fails

2016-01-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 January 2016 at 15:28:29 UTC, Adrian Matoga wrote: How can I reliably test if CallsFoo can be instantiated? You can use a constraint to prevent invalid instantiation: struct HasFoo { void foo() {} } struct NoFoo {} struct CallsFoo(T) if (__traits(hasMember, T, "foo")) {

Re: opApply @safety

2016-01-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 January 2016 at 17:44:34 UTC, Chris Wright wrote: I want to create an opApply for a type. I've marked my code @safe, because everything I wrote was @safe. The body of opApply is @safe, but it calls a delegate that may or may not be @safe. How do I make it so I can iterate throu

Re: is(some template instantiation) is true, but the actual instantiation fails

2016-01-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 January 2016 at 17:01:46 UTC, Adrian Matoga wrote: On Friday, 29 January 2016 at 16:36:01 UTC, Steven Schveighoffer wrote: On 1/29/16 10:28 AM, Adrian Matoga wrote: [...] is(T) is supposed to be false if T is not a valid type. I would agree with you that the static assert shoul

Re: Capturing a variable by value?

2016-02-03 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 18:09:52 UTC, ZombineDev wrote: I think these two links, more or less, answer my question: http://stackoverflow.com/questions/29759419/closures-in-loops-capturing-by-reference https://issues.dlang.org/show_bug.cgi?id=2043 Another approach: import std.range, std

Re: Can D interface with Free Pascal?

2016-02-08 Thread Basile B. via Digitalmars-d-learn
On Thursday, 28 January 2016 at 04:26:26 UTC, Taylor Hillegeist wrote: Just curious... I had a thought that perhaps since Objective C was a replacement for Pascal on the mac. that they might have the same interface. but I'm not savvy enough with fpc to figure out how to try it. As said in the

Re: How to warn of unused imports?

2016-02-08 Thread Basile B. via Digitalmars-d-learn
On Monday, 8 February 2016 at 08:50:17 UTC, Daniel Kozak wrote: V Mon, 08 Feb 2016 08:25:09 + cy via Digitalmars-d-learn napsáno: When I factor out code from my modules, it really, really often leaves import statements that just sit there doing nothing, making it look like my program is

Re: How do you reference variables in an AA of Variants?

2016-02-08 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 03:49:11 UTC, Enjoys Math wrote: This: double b = 1.0; Variant[string] aa = ["b": &b]; writeln(aa["b"]); fails with: Error: cannot implicitly convert expression(["b":&b]) of type double*[string] to VariantN!20u[string] Helps please!

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request for DMD. I know other compilers who do this warning. It definitely does sound like a decent enhancement request. I didn't

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote: On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request for DMD. I know other compilers who do this warning. It defi

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 17:54:30 UTC, Basile B. wrote: On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote: On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request

Re: Reserving capacity in associative arrays

2016-02-16 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 16 February 2016 at 16:37:07 UTC, Steven Schveighoffer wrote: There is not a public way to access these methods unfortunately. It would be a good addition to druntime I believe. Recently, I added a clear method to the AA, which does not reduce capacity. So if you frequently build l

Re: BZ2 library

2016-03-11 Thread Basile B. via Digitalmars-d-learn
On Saturday, 12 March 2016 at 05:16:37 UTC, stunaep wrote: I'm really having a hard time using bzp (and later I need gzip and lzma). So I added this bzip2 D interface to my DUB dependencies "dependencies" : { "bzip2": "~>0.1.0" } I downloaded the bzip2 source code and compiled

Re: BZ2 library

2016-03-12 Thread Basile B. via Digitalmars-d-learn
On Saturday, 12 March 2016 at 09:53:36 UTC, stunaep wrote: On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] On Saturday, 12 March 2016 at 09:04:08 UTC, stunaep wrote: On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] If I do "dflags" : ["lib/libbzip2

In D, lexically, which are the chars that can follow $, exactly ?

2016-03-13 Thread Basile B. via Digitalmars-d-learn
'$' is only valid in an indexExpression (https://dlang.org/spec/grammar.html#IndexExpression), so it can only be followed by - ' ' - ']' - operators , usually '-' but also '/', '+', '>>' etc Is that right ? I'd like to relax the lexical rule for C.E static macros which currently is - "^\$\

Re: In D, lexically, which are the chars that can follow $, exactly ?

2016-03-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 March 2016 at 14:55:36 UTC, Marc Schütz wrote: On Sunday, 13 March 2016 at 14:07:31 UTC, Basile B. wrote: '$' is only valid in an indexExpression (https://dlang.org/spec/grammar.html#IndexExpression), so it can only be followed by - ' ' - ']' - operators , usually '-' but also '

Re: How to list all version identifiers?

2016-03-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 March 2016 at 15:15:22 UTC, Iakh wrote: There is trick for gcc: gcc -dM -E - < /dev/null It shows all default #defines Is there way to show all version identifiers for D? For all or any compiler you know trivial answer, let's say you have dcd-server running in the background:

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

2016-03-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 March 2016 at 19:37:42 UTC, ParticlePeter wrote: I have a struct that privately warps an std.container.array. I would like to return a read-only reference of this array, it should not be duplicated. How can I do this? Cheers, ParticlePeter ref const(Array!Type) view(){} Unless

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

2016-03-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote: Unless the result is explicitly cast later it can't me modified. import std.stdio, std.container.array; struct Foo { private Array!int arr; ref const(Array!int) view() { return arr; } } void main(string[] args)

Re: How to list all version identifiers?

2016-03-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 March 2016 at 16:28:50 UTC, Iakh wrote: On Sunday, 13 March 2016 at 15:50:47 UTC, Basile B. wrote: trivial answer, let's say you have dcd-server running in the background: dcd-client -c8 <<< "version(" Thanks. Will try. But it was a joke actually. It works but this is not ver

Re: size_t index=-1;

2016-03-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 March 2016 at 09:33:25 UTC, tsbockman wrote: [...] The reason that *attempting* such a comparison produces such weird results, is because the signed value is being implicitly cast to an unsigned type. Yes and that's the opposite that should happend: when signed and unsigned ar

Re: size_t index=-1;

2016-03-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 March 2016 at 10:24:41 UTC, Ola Fosheim Grøstad wrote: On Saturday, 19 March 2016 at 10:01:41 UTC, Basile B. wrote: On Saturday, 19 March 2016 at 09:33:25 UTC, tsbockman wrote: [...] The reason that *attempting* such a comparison produces such weird results, is because the signe

Re: How do I extend an enum?

2016-03-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 March 2016 at 17:40:27 UTC, Lass Safin wrote: Why: enum Base { A, B, } enum Derived : Base { C, // Gives error, says it can't implicitly convert expression to Base. D = 1, // Same error E = cast(Base)294, // Finally works. Can only be cast(Derived) instead

Re: char array weirdness

2016-03-29 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: void main () { import std.range.primitives; char[] val = ['1', '0', 'h', '3', '6', 'm', '2', '8', 's']; pragma(msg, ElementEncodingType!(typeof(val))); pragma(msg, typeof(val.front)); } prints char dchar Why

Re: char array weirdness

2016-03-29 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 00:05:29 UTC, Steven Schveighoffer wrote: On 3/29/16 7:42 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Mar 29, 2016 at 11:15:26PM +, Basile B. via Digitalmars-d-learn wrote: On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: void main

Async read an output stream but how many bytes ?

2016-03-30 Thread Basile B. via Digitalmars-d-learn
Hey, I have a class that wraps a process and implements two events. One of them is called after poll() for example if new data are available. The event is called correctly but I don't know how exactly how to read the data: - per buffer of fixed size ? - using the stream information ? If i t

Re: Async read an output stream but how many bytes ?

2016-03-30 Thread Basile B. via Digitalmars-d-learn
On Thursday, 31 March 2016 at 01:12:50 UTC, Adam D. Ruppe wrote: On Thursday, 31 March 2016 at 00:50:16 UTC, Basile B. wrote: There should be a way to know how many bytes are available ? You are already using poll()... I'd just use read() directly on the file number too. It will read as much

Re: Async read an output stream but how many bytes ?

2016-03-31 Thread Basile B. via Digitalmars-d-learn
On Thursday, 31 March 2016 at 13:48:46 UTC, Steven Schveighoffer wrote: stdio.readf is buffered. It does not deal with async io properly I think. -Steve Yes, I must use core.sys.posix.unistd.read, which was actually what A.D.Ruppe suggested, I think.

Re: Convert wchar* to wstring?

2016-04-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 01:21:55 UTC, Thalamus wrote: I'm sorry for this total newbie question, but for some reason this is eluding me. [...] You've been given the right answer by the other participants but I'd like to share this simple helper range from my user lib: auto nullTerminated(

What's the rationale for considering "0x1.max" as invalid ?

2016-04-05 Thread Basile B. via Digitalmars-d-learn
0x1.max // exponent expected in hex float 0x1 .max // OK 1.max // OK What's the ambiguity when it's an hex literal ?

Re: What's the rationale for considering "0x1.max" as invalid ?

2016-04-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 19:00:43 UTC, Basile B. wrote: 0x1.max // exponent expected in hex float 0x1 .max // OK 1.max // OK What's the ambiguity when it's an hex literal ? https://issues.dlang.org/show_bug.cgi?id=15880

Re: What's the rationale for considering "0x1.max" as invalid ?

2016-04-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 20:56:54 UTC, Alex Parrill wrote: On Tuesday, 5 April 2016 at 19:00:43 UTC, Basile B. wrote: 0x1.max // exponent expected in hex float 0x1 .max // OK 1.max // OK What's the ambiguity when it's an hex literal ? It's potentially ambiguous with hexadecimal floating po

Re: What's the rationale for considering "0x1.max" as invalid ?

2016-04-05 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 21:10:47 UTC, Basile B. wrote: On Tuesday, 5 April 2016 at 20:56:54 UTC, Alex Parrill wrote: On Tuesday, 5 April 2016 at 19:00:43 UTC, Basile B. wrote: 0x1.max // exponent expected in hex float 0x1 .max // OK 1.max // OK What's the ambiguity when it's an hex literal

Re: More binary I/O problems

2016-04-08 Thread Basile B. via Digitalmars-d-learn
On Friday, 8 April 2016 at 20:58:06 UTC, Charles Hixson wrote: [...] And that worked, but suddenly (after a compiler upgrade, did that matter? I'd also changed the program, though in ways that shouldn't have affected this.) it stopped working with the message: let4a.d(138): Error: no [] opera

Re: More binary I/O problems

2016-04-08 Thread Basile B. via Digitalmars-d-learn
On Saturday, 9 April 2016 at 03:15:58 UTC, Charles Hixson wrote: On 04/08/2016 07:42 PM, Basile B. via Digitalmars-d-learn wrote: On Friday, 8 April 2016 at 20:58:06 UTC, Charles Hixson wrote: [...] And that worked, but suddenly (after a compiler upgrade, did that matter? I'd also ch

Re: foreach of classes

2016-04-09 Thread Basile B. via Digitalmars-d-learn
On Saturday, 9 April 2016 at 10:10:19 UTC, Lucien wrote: Hello. When I do: - class MyClass{..} class YourClass{..} class OurClass{..} YourClass yc = new YourClass(); foreach (auto id; [ typeid(MyClass), typeid(YourClass), typeid(OurClass) ]) { if (typeid(yc) == id) {

Re: foreach of classes

2016-04-09 Thread Basile B. via Digitalmars-d-learn
On Saturday, 9 April 2016 at 11:03:54 UTC, Nicholas Wilson wrote: On Saturday, 9 April 2016 at 10:56:34 UTC, Lucien wrote: On Saturday, 9 April 2016 at 10:28:05 UTC, Basile B. wrote: On Saturday, 9 April 2016 at 10:10:19 UTC, Lucien wrote: Hello. FYI the things that you can put there (in place

Re: Enabling Only Top-Level Unittests

2016-04-22 Thread Basile B. via Digitalmars-d-learn
On Thursday, 21 April 2016 at 19:38:21 UTC, Nordlöw wrote: On Thursday, 21 April 2016 at 12:35:42 UTC, Anonymouse wrote: Then dmd -unittest -version=TestDeps if you want them run. This doesn't make things easier. I want to disable the builtin unittests of the modules I've imported. This requi

Re: Enabling Only Top-Level Unittests

2016-04-23 Thread Basile B via Digitalmars-d-learn
On Friday, 22 April 2016 at 18:18:39 UTC, Basile B. wrote: I think a DMD option should be added to allow the tests to be compiled but never called, something like -runTests. Because the first solution is much more attractive. Actually the first solution works with: https://dlang.org/phobos/co

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 April 2016 at 17:06:07 UTC, rcorre wrote: On Saturday, 23 April 2016 at 00:55:07 UTC, rcorre wrote: On Friday, 22 April 2016 at 10:25:34 UTC, Chris wrote: [...] No luck with cmain.d. Its definitely an environmental problem -- I have an almost identical Archlinux desktop that

Re: relative benefit of .reserve and .length

2016-04-28 Thread Basile B. via Digitalmars-d-learn
On Thursday, 28 April 2016 at 12:56:24 UTC, Jay Norwood wrote: I timed some code recently and found that .reserve made almost no improvement when appending. It appears that the actual change to the length by the append had a very high overhead of something over 200 instructions executed, regar

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Basile B via Digitalmars-d-learn
On Sunday, 1 May 2016 at 13:22:27 UTC, Mithun Hunsur wrote: On Sunday, 1 May 2016 at 10:37:23 UTC, Anonymouse wrote: On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/

Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread Basile B via Digitalmars-d-learn
On Sunday, 1 May 2016 at 11:17:27 UTC, earthfront wrote: Hello! This code fails: - void main(){ class A { int b; private this(int a){b=a;} } //{ int b; this(int a){b=a;} } import std.conv:emplace; import std.experimental.allocator.mallocator:Mallocator; import

Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread Basile B via Digitalmars-d-learn
On Monday, 2 May 2016 at 04:19:48 UTC, earthfront wrote: On Sunday, 1 May 2016 at 19:18:38 UTC, Basile B wrote: CT make(CT, Alloc, A...)(auto ref Alloc al, A a) This works. Thank you. Good point about __ctor alone not being sufficient. auto memory = al.allocate(size); ... GC

Re: inferred size for static array initialization

2016-05-02 Thread Basile B via Digitalmars-d-learn
On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definitions. The code below doesn't work whe

Re: inferred size for static array initialization

2016-05-02 Thread Basile B via Digitalmars-d-learn
On Monday, 2 May 2016 at 13:22:01 UTC, Basile B wrote: On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer st

Re: inferred size for static array initialization

2016-05-03 Thread Basile B. via Digitalmars-d-learn
On Monday, 2 May 2016 at 17:43:56 UTC, Namespace wrote: I still like auto s(T, size_t n)(T[n] arr) { return arr; } Wooah, this trick is awesome. But actually it does the same thing that what I've proposed before. Exactly the same code is generated. So I'd say that it's rather a

Re: Code example for function/delegate as template argument ?

2016-05-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 06:21:36 UTC, chmike wrote: Hello, I failed to find some code example for a template class/struct that accept a function/delegate as template argument. All examples I could find use simple value types like int or double. I piggy bag another question. Defining a f

Re: Code example for function/delegate as template argument ?

2016-05-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 06:21:36 UTC, chmike wrote: Hello, I failed to find some code example for a template class/struct that accept a function/delegate as template argument. All examples I could find use simple value types like int or double. I piggy bag another question. Defining a f

Re: Code example for function/delegate as template argument ?

2016-05-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 10:58:04 UTC, chmike wrote: On Wednesday, 4 May 2016 at 06:59:00 UTC, Basile B. wrote: . . . void main(string[] args) { alias fun = (a) => a.writeln; auto foo = Foo!fun("hello"); } Is this equivalent to Foo!(a => a.writeln) or is it required to split this i

Re: Code example for function/delegate as template argument ?

2016-05-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 11:19:59 UTC, chmike wrote: I think you misunderstood the second question. Here is another attempt with an example. // function accepting a function as argument void foo(function void fg(int)) { fg(5); } // A class with a none static method with the same signatu

immutable shared not accepted as TypeCtor ?

2016-05-19 Thread Basile B. via Digitalmars-d-learn
void main() { alias T = immutable(shared(int)); static assert(is(T==immutable)); static assert(is(T==shared)); } It probably doesn't make sense to have immutable shared data but the grammar indicates that there can be many of them without any explicit restriction. Is it

Re: Overload new and delete to not use GC?

2016-05-22 Thread Basile B. via Digitalmars-d-learn
On Sunday, 22 May 2016 at 07:35:32 UTC, Rusty wrote: I know it's possible to do [explicit object allocation](http://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation) on the heap, but I find that quite cumbersome. So.. is it possible to overload 'new' and 'delete' to not use

Re: Problem with .debug info in program

2016-05-24 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 13:17:22 UTC, chmike wrote: After closer examination it seam that the second line with 9 is a bogus insertion. Removing it should fix the code line table. app.d 9 0x43aafb app.d 11

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: Hi everybody, [...] 5 - Tools I've seen your comment on the DCD issue related to DUB (#198). It mays be the plugin (and not DCD ) that doesn't register well vibe-d. Also it's possible that it didn't work because vibe-d was not yet fetch

Re: Effect of declaring a class immutable ?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 14:12:23 UTC, chmike wrote: I couldn't find any information about this on the dlang web site. What is the effect adding the immutable attribute to a class like this immutable class MyClass { ... } The compiler doesn't complain. Will it add the immutable attribute

<    1   2   3   4   5   6   7   8   >