Re: std.data.json formal review

2015-08-17 Thread Sönke Ludwig via Digitalmars-d
Am 17.08.2015 um 22:58 schrieb Suliman: String is a valid range, but parseJSONValue takes a *reference* to a range, because it directly consumes the range and leaves anything that appears after the JSON value in the range. toJSON() on the other hand assumes that the JSON value occupies the whole

Equality of `pred` Template Parameters

2015-08-17 Thread via Digitalmars-d
In https://github.com/D-Programming-Language/phobos/pull/3534 I'm in need of a generic and correct definition of template isSortedRange(T, alias pred = a b) at https://github.com/D-Programming-Language/phobos/pull/3534/files#diff-9f63c74383984a09f5bf578493892e27R1005 To make it general

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 16 August 2015 at 23:05:42 UTC, Ali Çehreli wrote: // Now the type of d is a template parameter @nogc auto func(Func)(uint[] arr, Func d) { return arr.map!(d); } Huh. I think func being a template is the key here. When the original code is put in a template, it works too (with

[Issue 14724] std.getopt: config.required breaks --help

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14724 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/6c8b8232c30c38cd2140625225e0b7211a4319ae fix issue14724 some

[Issue 14724] std.getopt: config.required breaks --help

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14724 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED

Re: Theoretical Best Practices

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/14/15 6:25 PM, DarthCthulhu wrote: On Friday, 14 August 2015 at 12:40:08 UTC, Steven Schveighoffer wrote: I would do it this way: // at module level debug(logging) { Logger logger; static this() { logger = new Logger;} } By 'module level', I assume you mean in the module that

Re: Passing parameters to thread functions

2015-08-17 Thread via Digitalmars-d
On Saturday, 15 August 2015 at 23:45:29 UTC, deadalnix wrote: Delegate do not come with a type qualifier for their payload, so there is no way to do otherwize. Looks like they do: alias X = void delegate() const; void z(X fun) { fun(); } void main() { int a; z({ a

[Issue 14926] Programs compiled using dmd 2.068 are generating dummy profilegc.log files

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14926 ag0ae...@gmail.com changed: What|Removed |Added CC||ag0ae...@gmail.com

Re: Equality of `pred` Template Parameters

2015-08-17 Thread via Digitalmars-d
On Monday, 17 August 2015 at 09:23:56 UTC, Per Nordlöw wrote: To make it general we want it to support `pred` argument of types other than `string`, typically If binaryFun!... are used as template alias parameters in all cases is it currently possible to compare these lambdas for equality?

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 09:51:47 UTC, anonymous wrote: Huh. I think func being a template is the key here. When the original code is put in a template, it works too (with 2.068): Nope, it works only because r is unreferenced and gets thrown out. Just try using r.front there, for example,

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 8/17/15 2:47 PM, Dmitry Olshansky wrote: Actually one can combine the two: - use integer type tag for everything built-in - use pointer tag for what is not But a pointer tag can do everything that an integer tag does. -- Andrei

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 8/17/15 2:51 PM, deadalnix wrote: From the compiler perspective, the tag is much nicer. Compiler can use jump table for instance. The pointer is a more direct conduit to a jump table. It is not a good solution for Variant (which needs to be able to represent arbitrary types) but if the

unusual bare metal target: Amazon Dash

2015-08-17 Thread Laeeth Isharc via Digitalmars-d-learn
I don't know whether D can run on one, but from a quick look perhaps feasible. Running D on something like this (perhaps it's underpowered, but looked to have similar spec to what people had been doing with related ARM cortex processors) would certainly make the point very vivid that it can

Re: else if for template constraints

2015-08-17 Thread Idan Arye via Digitalmars-d
On Monday, 17 August 2015 at 21:27:47 UTC, Meta wrote: On Monday, 17 August 2015 at 17:17:15 UTC, Steven Schveighoffer wrote: On 8/17/15 1:00 PM, Idan Arye wrote: It looks a bit ugly, that the `else` is after a function declaration instead of directly after the if's then clause. How about

Re: else if for template constraints

2015-08-17 Thread anonymous via Digitalmars-d
On Monday, 17 August 2015 at 22:32:10 UTC, Idan Arye wrote: On Monday, 17 August 2015 at 21:27:47 UTC, Meta wrote: [...] At that point, couldn't you just use static if inside the body of the template instead of using template constraints? No. Consider this:

[Issue 14927] New: GDB cannot be used to debug D programs on OS X

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14927 Issue ID: 14927 Summary: GDB cannot be used to debug D programs on OS X Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: major

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 8/17/15 2:56 PM, Sönke Ludwig wrote: - The enum is useful to be able to identify the types outside of the D code itself. For example when serializing the data to disk, or when communicating with C code. OK. - It enables the use of pattern matching (final switch), which is often very

[Issue 14928] New: Switches -betterC and -m32mscoff do not appear in DMD's help text

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14928 Issue ID: 14928 Summary: Switches -betterC and -m32mscoff do not appear in DMD's help text Product: D Version: D2 Hardware: All OS: All Status: NEW

Re: else if for template constraints

2015-08-17 Thread BBasile via Digitalmars-d
On Monday, 17 August 2015 at 22:44:15 UTC, anonymous wrote: On Monday, 17 August 2015 at 22:32:10 UTC, Idan Arye wrote: On Monday, 17 August 2015 at 21:27:47 UTC, Meta wrote: [...] At that point, couldn't you just use static if inside the body of the template instead of using template

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 17:48:22 UTC, D_Learner wrote: On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: [...] The surprisingly, the D-profiler gives plausible results:- Algorithm1 2921 int rtime_pre.bm_rmatch (runtime ) 2122 int ctime_pre.bm_cmatch

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 7/28/15 10:07 AM, Atila Neves wrote: Start of the two week process, folks. Code: https://github.com/s-ludwig/std_data_json Docs: http://s-ludwig.github.io/std_data_json/ Atila I'll preface my review with a general comment. This API comes at an interesting juncture; we're striving as much

Re: Getting a TypeTuple of a Template's Arguments

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
Aside: With 2.068, std.typetuple and TypeTuple are renamed as std.meta and AliasSeq, respectively. On 08/17/2015 02:23 PM, Meta wrote: For functions, we have std.traits.ParameterTypeTuple. Is there any equivalent functionality for templates? There is TemplateArgsOf for instances of

Re: std.net.curl

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:13:48 UTC, anonymous wrote: and figured out that the linker is invoked (on my machine) with gcc a.o -o a -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker correct (I named the example programm a.d instead of app.d): gcc app.o -o app -m64 -lcurl

Re: else if for template constraints

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d
On 8/17/15 9:18 AM, Steven Schveighoffer wrote: The issue (as I noted in the bug report), is that the array being replaced is some string, and the element type of the stuff to replace is a dchar. But the first version is better for replacing a char[] in a char[], and works just fine. I guess

[Issue 14925] replaceInPlace fail compilation

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14925 Steven Schveighoffer schvei...@yahoo.com changed: What|Removed |Added Hardware|x86 |All

Re: Equality of `pred` Template Parameters

2015-08-17 Thread Timon Gehr via Digitalmars-d
On 08/17/2015 12:13 PM, Per =?UTF-8?B?Tm9yZGzDtnci?= per.nord...@gmail.com wrote: On Monday, 17 August 2015 at 09:23:56 UTC, Per Nordlöw wrote: To make it general we want it to support `pred` argument of types other than `string`, typically If binaryFun!... are used as template alias

[Issue 14925] replaceInPlace fail compilation

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14925 Steven Schveighoffer schvei...@yahoo.com changed: What|Removed |Added CC|

Re: std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:26:29 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: Error: unrecognized switch '-lcurl' ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d` Yes, it did the trick.

std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
Hi, I'm trying to compile this trivial example of std.net.curl: // app.d import std.stdio; import std.net.curl; void main() { auto content = get(dlang.org); } Hovewer, dmd app.d spits a whole bunch of strange error messages: /usr/lib64/libphobos2.a(curl.o): In function

Re: std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, dmd app.d spits a whole bunch of strange error messages: try dmd -lcurl app.d and see if that helps. Error: unrecognized switch '-lcurl'

Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
Hello everyone . I need advice on my first D-project . I have uploaded it at :- https://bitbucket.org/mrjohns/matcher/downloads IDEA : Benchmarking of 3 runtime algorithms and comparing them to their compile-time variants. The only difference between these is that for the compile time-ones,

Re: Equality of `pred` Template Parameters

2015-08-17 Thread Timon Gehr via Digitalmars-d
On 08/17/2015 02:33 PM, Timon Gehr wrote: enum binaryFunString(alias x:binaryFun!T,T...)=T[0]; static assert(binaryFunString!x==a+b); static assert(binaryFunString!y==a+b); static assert(binaryFunString!z==a-b); Note that the remaining template arguments to binaryFun are important as well,

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 10:28:33 UTC, thedeemon wrote: Nope, it works only because r is unreferenced and gets thrown out. Just try using r.front there, for example, and the error returns. You're right, it falls short. But I think r not being referenced is not exactly it. Using front in

Re: std.net.curl

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, dmd app.d spits a whole bunch of strange error messages: try dmd -lcurl app.d and see if that helps.

else if for template constraints

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d
I was just looking at fixing this bug:https://issues.dlang.org/show_bug.cgi?id=14925 A little background for the root cause: replaceInPlace has 2 versions. One is a specialized version that replaces the actual elements in an array with another array of the same type. The second version

Re: D for project in computational chemistry

2015-08-17 Thread jmh530 via Digitalmars-d
On Sunday, 16 August 2015 at 13:11:12 UTC, Yura wrote: Python: #!/usr/bin/python import sys, string, os, glob, random from math import * a = 0 l = 1000 for i in range(l): for j in range(l): for m in range(l): a = a +i*i*0.7+j*j*0.8+m*m*0.9

Re: std.net.curl

2015-08-17 Thread yawniek via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, dmd app.d spits a whole bunch of strange error messages: try dmd -lcurl app.d and see if that

Re: std.net.curl

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, dmd app.d spits a whole bunch of strange error messages: try dmd -lcurl app.d and see if that helps. DMD does not accept -lcurl. From dmd --help:

Re: Pointers to Dynamic Arrays

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:27:19 UTC, Brandon Ragland wrote: If that is true, than passing it as _char[] file_ makes the most sense to me. A pointer copy doesn't hurt as bad as an array copy, of say, 100Kibibytes... Right. Knowing this helps to explain a lot btw: char[] foo; void

Re: Equality of `pred` Template Parameters

2015-08-17 Thread via Digitalmars-d
On Monday, 17 August 2015 at 12:33:28 UTC, Timon Gehr wrote: import std.functional: binaryFun; alias x=binaryFun!a+b; alias y=binaryFun!a+b; static assert(__traits(isSame,x,y)); Not quite what we want, because alias x=binaryFun!a+b; alias y=binaryFun!a + b; static

Re: Pointers to Dynamic Arrays

2015-08-17 Thread Brandon Ragland via Digitalmars-d-learn
On Monday, 17 August 2015 at 03:07:26 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 02:45:22 UTC, Brandon Ragland wrote: [...] Short answer: pointers to slices are usually a mistake, you probably don't actually want it, but rather should be using a regular slice instead. [...]

Re: std.net.curl

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: Error: unrecognized switch '-lcurl' ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d`

[Issue 14925] replaceInPlace fail compilation

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14925 --- Comment #2 from Steven Schveighoffer schvei...@yahoo.com --- Hm... I was wrong I guess (sort of). The *second* overload is the one that should be chosen. This means that even though the replace could be done directly, it will reallocate. This is

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Benjamin Thaut via Digitalmars-d
On Monday, 17 August 2015 at 20:33:45 UTC, welkam wrote: I might be wrong, but he should worry about GC before he removes that memory range from GC managed list not after. And his code smells to me. He gives full memory control to GC, but then wants to take it away, fiddle and give it back. I

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Benjamin Thaut via Digitalmars-d
On Monday, 17 August 2015 at 19:38:21 UTC, Steven Schveighoffer wrote: On 8/17/15 3:27 PM, Benjamin Thaut wrote: Consider the following code void* mem = malloc(500); GC.addRange(mem, 500); mem = realloc(mem, 512); // assume the pointer didn't change GC.removeRange(mem); This is actually

Re: unusual bare metal target: Amazon Dash

2015-08-17 Thread Rikki Cattermole via Digitalmars-d-learn
On 18/08/2015 1:32 p.m., Laeeth Isharc wrote: I don't know whether D can run on one, but from a quick look perhaps feasible. Running D on something like this (perhaps it's underpowered, but looked to have similar spec to what people had been doing with related ARM cortex processors) would

Re: else if for template constraints

2015-08-17 Thread Timon Gehr via Digitalmars-d
On 08/17/2015 03:18 PM, Steven Schveighoffer wrote: Can we do something like this? I'm not a compiler guru, so I defer to you experts out there. Implementation is trivial. (A naive implementation strategy which works is to just use the obvious lowering.)

Re: A couple questions about a simple project

2015-08-17 Thread FreeSlave via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:38:05 UTC, anonymous wrote: auto func()(uint[] arr, uint delegate(uint) pure @nogc d) @nogc { return arr.map!(d); } void main() @nogc { uint[3] arr = [1,2,3]; uint context = 2; auto c = Caller(context); auto d = c.method; auto r =

Re: else if for template constraints

2015-08-17 Thread Idan Arye via Digitalmars-d
On Monday, 17 August 2015 at 13:18:43 UTC, Steven Schveighoffer wrote: void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff) if(isDynamicArray!Range is(Unqual!(ElementEncodingType!Range) == T) !is(T == const T) !is(T == immutable T)) { /* version 1

Re: else if for template constraints

2015-08-17 Thread Zoadian via Digitalmars-d
On Monday, 17 August 2015 at 16:57:33 UTC, Zoadian wrote: wouldn't is(typeof(replace(array, from, to, stuff))) better be a static if inside the first version? nevermind, I missed that the first constraint is negated. In that case I agree, else if would be nice.

Parallelizing control flow

2015-08-17 Thread welkam via Digitalmars-d
Hi, I was looking at this talk from one of backend developers of Microsoft's c++ compiler. link: https://youtu.be/Edzh_e1rqCo?t=40m49s He was talking about parallelizing control flow and why this optimization cant be done to c++ code. Spoiler: because c++ variables are shared across

Re: Weird error message.

2015-08-17 Thread Kagamin via Digitalmars-d-learn
On Sunday, 16 August 2015 at 21:32:10 UTC, Warwick wrote: Dont know what to make of this, I pretty much get it every other time I call rdmd. It'll alternate between running fine and then giving me this error... Any ideas? rdmd creates an executable and runs it immediately. If you have an

Re: else if for template constraints

2015-08-17 Thread Zoadian via Digitalmars-d
On Monday, 17 August 2015 at 13:18:43 UTC, Steven Schveighoffer wrote: void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff) if(isDynamicArray!Range is(Unqual!(ElementEncodingType!Range) == T) !is(T == const T) !is(T == immutable T)) { /* version 1

Re: Weird error message.

2015-08-17 Thread Kagamin via Digitalmars-d-learn
On Monday, 17 August 2015 at 03:14:24 UTC, BBasile wrote: It's locked unless it's specified during the call to `CreateFile()` that the file can be shared for reading/writing (FILE_SHARE_READ / FILE_SHARE_WRITE). And the executable file being run must not be shared for writing, because it's

Re: A couple questions about a simple project

2015-08-17 Thread Andre Polykanine via Digitalmars-d-learn
Hello John, Yes, but this doesn't work, either. Now I have this (that was my first variant, btw): string s; try { s = cast(string)std.file.read(f); try

Re: A couple questions about a simple project

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
On 08/17/2015 10:08 AM, Andre Polykanine via Digitalmars-d-learn wrote: string s; try { s = cast(string)std.file.read(f); try {

Re: mood : simple vibe.d based blog implementation

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 8/14/15 2:51 PM, Dicebot wrote: A bit more details - https://blog.dicebot.lv/posts/2015/08/In_the_mood_for_some_releasing Project repo - https://github.com/Dicebot/mood Branch which powers actual blog.dicebot.lv - https://github.com/Dicebot/mood/tree/blog.dicebot.lv Copy of feature list for

Re: else if for template constraints

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d
On 8/17/15 1:00 PM, Idan Arye wrote: It looks a bit ugly, that the `else` is after a function declaration instead of directly after the if's then clause. How about doing it with the full template style? template replaceInPlace(T, Range) if(isDynamicArray!Range

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern=GCAGAGAG are as below :- BM_Runtime = 366

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern=GCAGAGAG are as below :- BM_Runtime = 366 hnsecs position= 513 BM_Compile-time = 294 hnsecs

Re: A couple questions about a simple project

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern=GCAGAGAG are as below :- BM_Runtime = 366

Re: D for project in computational chemistry

2015-08-17 Thread John Colvin via Digitalmars-d
On Sunday, 16 August 2015 at 13:59:33 UTC, Idan Arye wrote: Initially I thought the Python version is so slow because it uses `range` instead of `xrange`, but I tried them both and they both take about the same, so I guess the Python JIT(or even interpreter!) can optimize these allocations

A couple questions about a simple project

2015-08-17 Thread Andre Polykanine via Digitalmars-d-learn
Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid questions. I've made a toy project which is a small command-line

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 7/28/15 10:07 AM, Atila Neves wrote: Start of the two week process, folks. Code: https://github.com/s-ludwig/std_data_json Docs: http://s-ludwig.github.io/std_data_json/ Atila I'll submit a review in short order, but thought this might be of use in performance comparisons:

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote: I've just checked with my runtime GC hook. Here the call to func() allocates 12 bytes via gc_malloc, and it's the same for a 4-elements array, so it's not for the array itself, it's for a closure, I think. Also, compiling with -vgc

perpetual: new module for mapping file into memory

2015-08-17 Thread Sergei Degtiarev via Digitalmars-d-announce
I suggests a new module for mapping files into memory. Instead of viewing the file as array of bytes, it directly maps the object onto file allowing to handle it as regular in-memory object. The data remain persistent after the program exits and may be re-opened and used again or shared

Re: std.data.json formal review

2015-08-17 Thread deadalnix via Digitalmars-d
On Monday, 17 August 2015 at 18:12:02 UTC, Andrei Alexandrescu wrote: On 8/14/15 7:40 AM, Andrei Alexandrescu wrote: On 8/12/15 5:43 AM, Sönke Ludwig wrote: Anyway, I've just started to work on a generic variant of an enum based algebraic type that exploits as much static type information as

Re: std.data.json formal review

2015-08-17 Thread Dmitry Olshansky via Digitalmars-d
On 17-Aug-2015 21:12, Andrei Alexandrescu wrote: On 8/14/15 7:40 AM, Andrei Alexandrescu wrote: On 8/12/15 5:43 AM, Sönke Ludwig wrote: Anyway, I've just started to work on a generic variant of an enum based algebraic type that exploits as much static type information as possible. If that

Re: std.data.json formal review

2015-08-17 Thread Sönke Ludwig via Digitalmars-d
Am 17.08.2015 um 20:12 schrieb Andrei Alexandrescu: On 8/14/15 7:40 AM, Andrei Alexandrescu wrote: struct TaggedAlgebraic(U) if (is(U == union)) { ... } Interesting. I think it would be best to rename it to TaggedUnion (instantly recognizable; also TaggedAlgebraic is an oxymoron as there's no

Re: perpetual: new module for mapping file into memory

2015-08-17 Thread Liam McSherry via Digitalmars-d-announce
On Monday, 17 August 2015 at 18:27:48 UTC, Sergei Degtiarev wrote: [...] There is already this in Phobos: http://dlang.org/phobos/std_mmfile.html Is there any difference between `std.mmfile` and your solution?

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 16:21:16 UTC, thedeemon wrote: On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote: I've just checked with my runtime GC hook. Here the call to func() allocates 12 bytes via gc_malloc, and it's the same for a 4-elements array, so it's not for the array

Re: std.data.json formal review

2015-08-17 Thread Andrei Alexandrescu via Digitalmars-d
On 8/14/15 7:40 AM, Andrei Alexandrescu wrote: On 8/12/15 5:43 AM, Sönke Ludwig wrote: Anyway, I've just started to work on a generic variant of an enum based algebraic type that exploits as much static type information as possible. If that works out (compiler bugs?), it would be a great thing

[Issue 14926] New: Programs compiled using dmd 2.068 are generating dummy profilegc.log files

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14926 Issue ID: 14926 Summary: Programs compiled using dmd 2.068 are generating dummy profilegc.log files Product: D Version: D2 Hardware: x86 OS: Linux

Re: Just updated to 2.068, get random profilegc.log created all over the place

2015-08-17 Thread deadalnix via Digitalmars-d
On Sunday, 16 August 2015 at 23:41:28 UTC, Walter Bright wrote: On 8/16/2015 4:16 PM, deadalnix wrote: It looks like every run of whatever I compiled generate a profilegc.log file, that only contains : bytes allocated, type, function, file:line And that's it. Flag used to compile are -w

Re: perpetual: new module for mapping file into memory

2015-08-17 Thread Sergei Degtiarev via Digitalmars-d-announce
On Monday, 17 August 2015 at 19:00:37 UTC, Liam McSherry wrote: Is there any difference between `std.mmfile` and your solution? Implementation at system level is similar, the approach is different. std.mmfile returns uninitialized chunk of memory, std.perpetual returns an object which can be

Re: std.data.json formal review

2015-08-17 Thread Johannes Pfau via Digitalmars-d
Am Mon, 17 Aug 2015 20:56:18 +0200 schrieb Sönke Ludwig slud...@outerproduct.org: Am 17.08.2015 um 20:12 schrieb Andrei Alexandrescu: On 8/14/15 7:40 AM, Andrei Alexandrescu wrote: struct TaggedAlgebraic(U) if (is(U == union)) { ... } Interesting. I think it would be best to rename it

Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Benjamin Thaut via Digitalmars-d
Consider the following code void* mem = malloc(500); GC.addRange(mem, 500); mem = realloc(mem, 512); // assume the pointer didn't change GC.removeRange(mem); // if the GC kicks in here we're f* GC.addRange(mem, 512); I digged into GC.addRange to find out if I simply can skip the call to

Re: std.data.json formal review

2015-08-17 Thread Suliman via Digitalmars-d
Why not working: JSONValue x = parseJSONValue(`{a: true, b: test}`); but: string str = `{a: true, b: test}`; JSONValue x = parseJSONValue(str); work fine?

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d
On 8/17/15 3:27 PM, Benjamin Thaut wrote: Consider the following code void* mem = malloc(500); GC.addRange(mem, 500); mem = realloc(mem, 512); // assume the pointer didn't change GC.removeRange(mem); This is actually unsafe, you have to remove the range first, or else if it *does* change the

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread welkam via Digitalmars-d
// if the GC kicks in here we're f* Why? static nothrow @nogc void removeRange(in void* p); Removes the memory range starting at p from an internal list of ranges to be scanned during a collection. ...

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Walter Bright via Digitalmars-d
On 8/17/2015 12:38 PM, Steven Schveighoffer wrote: On 8/17/15 3:27 PM, Benjamin Thaut wrote: void* mem = malloc(500); GC.addRange(mem, 500); mem = realloc(mem, 512); // assume the pointer didn't change GC.removeRange(mem); This is actually unsafe, you have to remove the range first, or else

Re: std.data.json formal review

2015-08-17 Thread Sönke Ludwig via Digitalmars-d
I've added some changes in the latest version (docs updated): - Switched to TaggedAlgebraic with full static operator forwarding - Removed toPrettyJSON (now the default), added GeneratorOptions.compact - The bigInt field in JSONValue is now stored as a pointer - Removed

Re: std.data.json formal review

2015-08-17 Thread Suliman via Digitalmars-d
Also could you look at theme http://stackoverflow.com/questions/32033817/how-to-insert-date-to-arangodb And suggest your variant or approve on of existent.

Getting a TypeTuple of a Template's Arguments

2015-08-17 Thread Meta via Digitalmars-d-learn
For functions, we have std.traits.ParameterTypeTuple. Is there any equivalent functionality for templates?

Re: else if for template constraints

2015-08-17 Thread Meta via Digitalmars-d
On Monday, 17 August 2015 at 17:17:15 UTC, Steven Schveighoffer wrote: On 8/17/15 1:00 PM, Idan Arye wrote: It looks a bit ugly, that the `else` is after a function declaration instead of directly after the if's then clause. How about doing it with the full template style? template

Real OOP with D

2015-08-17 Thread Ozan via Digitalmars-d-learn
Hi Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work: import std.stdio; class Family { } class Dad : Family { void greeting() { writeln(I'm dad); } } class Boy :

Re: Real OOP with D

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
On 08/16/2015 10:57 PM, Ozan wrote: Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work: import std.stdio; class Family { } From the way you use it below, a better

[Issue 14776] shared library test - loadDR - segfaults on FreeBSD 10 when not building with -release

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14776 --- Comment #1 from github-bugzi...@puremagic.com --- Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/5f6c43131527749f6a3675ba4408bdfb90f2052b fix check for copy

[Issue 14776] shared library test - loadDR - segfaults on FreeBSD 10 when not building with -release

2015-08-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14776 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED

Re: Real OOP with D

2015-08-17 Thread BBasile via Digitalmars-d-learn
On Monday, 17 August 2015 at 05:57:52 UTC, Ozan wrote: Hi Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work: import std.stdio; class Family { } class Dad : Family

Re: Real OOP with D

2015-08-17 Thread Rikki Cattermole via Digitalmars-d-learn
On 17/08/2015 5:57 p.m., Ozan wrote: Hi Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work: import std.stdio; class Family { } class Dad : Family { void greeting() {

Re: mood : simple vibe.d based blog implementation

2015-08-17 Thread Walter Bright via Digitalmars-d-announce
On 8/17/2015 10:00 AM, Andrei Alexandrescu wrote: Tried to submit this, someone already did: https://www.reddit.com/r/programming/comments/3hbvrb/mood_simple_vibed_based_blog/ -- Andrei Dicebot, please post something there describing Mood to start the discussion.

Re: std.data.json formal review

2015-08-17 Thread Suliman via Digitalmars-d
Also I can't build last build from git. I am getting error: source\stdx\data\json\value.d(25,8): Error: module taggedalgebraic is in file 'taggedalgebraic.d' which cannot be read

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread welkam via Digitalmars-d
On Monday, 17 August 2015 at 20:07:08 UTC, Steven Schveighoffer wrote: On 8/17/15 3:57 PM, welkam wrote: // if the GC kicks in here we're f* Why? static nothrow @nogc void removeRange(in void* p); Removes the memory range starting at p from an internal list of ranges to be scanned

Re: std.data.json formal review

2015-08-17 Thread Sönke Ludwig via Digitalmars-d
Am 17.08.2015 um 22:31 schrieb Suliman: Also I can't build last build from git. I am getting error: source\stdx\data\json\value.d(25,8): Error: module taggedalgebraic is in file 'taggedalgebraic.d' which cannot be read Do you use DUB to build? It should automatically download the

Re: std.data.json formal review

2015-08-17 Thread Sönke Ludwig via Digitalmars-d
Am 17.08.2015 um 22:23 schrieb Suliman: On Monday, 17 August 2015 at 20:07:24 UTC, Sönke Ludwig wrote: toJSONValue() is the right function in this case. I've update the docs/examples to make that clearer. I think that I miss understanding conception of ranges. I reread docs but can't

Re: std.data.json formal review

2015-08-17 Thread Suliman via Digitalmars-d
String is a valid range, but parseJSONValue takes a *reference* to a range, because it directly consumes the range and leaves anything that appears after the JSON value in the range. toJSON() on the other hand assumes that the JSON value occupies the whole input range. Yeas, I understood,

Re: Safely extend the size of a malloced memory block after realloc

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d
On 8/17/15 3:57 PM, welkam wrote: // if the GC kicks in here we're f* Why? static nothrow @nogc void removeRange(in void* p); Removes the memory range starting at p from an internal list of ranges to be scanned during a collection. ... Because presumably the reason why you have added the

  1   2   >