Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 00:48, schrieb Brian Schott: On Thursday, 21 August 2014 at 22:35:18 UTC, Sönke Ludwig wrote: Destroy away! ;) source/stdx/data/json/lexer.d(263:8)[warn]: 'JSONToken' has method 'opEquals', but not 'toHash'. source/stdx/data/json/lexer.d(499:65)[warn]: Use parenthesis to clarify

Re: Automated source translation of C++ to D

2014-08-22 Thread Daniel Murphy via Digitalmars-d
"Joakim" wrote in message news:ynfwlptfuzfutksbn...@forum.dlang.org... Yes, I'm aware of ddmd. You've mentioned many times that it only works because dmd is written using a very unC++-like style, to the point where github's source analyzer claims that dmd is written in 66.7% C, 28.4% D (pres

Re: scope classes mentioned in tutorials, but deprecated

2014-08-22 Thread Jacob Carlborg via Digitalmars-d
On 21/08/14 20:07, Brad Anderson wrote: On Thursday, 21 August 2014 at 17:55:19 UTC, Timothee Cour via Digitalmars-d wrote: http://dlang.org/cpptod.html#raii mentions scope class and scope variables, which seem deprecated (http://dlang.org/deprecate.html) https://github.com/D-Programming-Langu

Re: scope classes mentioned in tutorials, but deprecated

2014-08-22 Thread bearophile via Digitalmars-d
Jacob Carlborg: How about we undeprecate it instead. If I recall correctly then DDMD depends on it. I think the idea is to discourage their usage as much as possible in user code, until (someday, perhaps) some memory area tracking system is implemented. Bye, bearophile

Re: Automated source translation of C++ to D

2014-08-22 Thread David Nadlinger via Digitalmars-d
On Friday, 22 August 2014 at 07:48:30 UTC, Daniel Murphy wrote: So no, you can't magically upgrade a project from C++ to D. Hence the name "magicport"? Sorry, could not resist. David

Re: scope classes mentioned in tutorials, but deprecated

2014-08-22 Thread Daniel Murphy via Digitalmars-d
"Jacob Carlborg" wrote in message news:lt6u0n$18mj$1...@digitalmars.com... How about we undeprecate it instead. If I recall correctly then DDMD depends on it. It's listed as 'future', so it's not actually deprecated. While DDMD does currently use it extensively, it can be replaced if necess

Re: Automated source translation of C++ to D

2014-08-22 Thread Daniel Murphy via Digitalmars-d
"David Nadlinger" wrote in message news:jumhdppapovcvfnwn...@forum.dlang.org... On Friday, 22 August 2014 at 07:48:30 UTC, Daniel Murphy wrote: > So no, you can't magically upgrade a project from C++ to D. Hence the name "magicport"? Sorry, could not resist. David It's only the illusion of

Re: Automated source translation of C++ to D

2014-08-22 Thread ketmar via Digitalmars-d
On Fri, 22 Aug 2014 08:29:52 + David Nadlinger via Digitalmars-d wrote: > Hence the name "magicport"? magic is not easy, contrary to widespread beliefs. ;-) signature.asc Description: PGP signature

Some template code that worked in 2.065 is not working in 2.066

2014-08-22 Thread Uranuz via Digitalmars-d
In my project I have sort of complicated logic to implement data structure that is somehow similar to std.typecons.Tuple. I can't reproduce it, because I can't locate the source of bug. My code is like this but have more nested template "calls". import std.stdio, std.typetuple; struct MyLib(A

Re: Shouldn't have IsAlpha() from std.uni has a different name to avoid confusing from std.ascii?

2014-08-22 Thread Uranuz via Digitalmars-d
On Thursday, 21 August 2014 at 15:36:41 UTC, ketmar via Digitalmars-d wrote: On Thu, 21 Aug 2014 15:27:46 + MacAsm via Digitalmars-d wrote: Any thoughts? I don't know if I'm missing something but two functions (and not methods) with same name is very bad. they doing much the same, but for

Re: $100 bounty for help with Windows Service code

2014-08-22 Thread Kagamin via Digitalmars-d
https://github.com/duovia/WindowsServiceInD/blob/master/src/onedge/mysvc.d#L20 these are not necessarily static: it makes sense to have instance fields of shared types too.

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 00:35, schrieb Sönke Ludwig: The DOM style JSONValue type is based on std.variant.Algebraic. This currently has a few usability issues that can be solved by upgrading/fixing Algebraic: - Operator overloading only works sporadically - (...) - Operations and conversions between

Re: RFC: std.json sucessor

2014-08-22 Thread matovitch via Digitalmars-d
Very nice ! I had started (and dropped) a json module based on Algebraic too. So without opDispatch you plan to use a syntax like jPerson["age"] = 10 ? You didn't use stdx.d.lexer. Any reason why ? (I am asking even if I never used this module.(never coded much in D in fact))

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 14:17, schrieb matovitch: Very nice ! I had started (and dropped) a json module based on Algebraic too. So without opDispatch you plan to use a syntax like jPerson["age"] = 10 ? You didn't use stdx.d.lexer. Any reason why ? (I am asking even if I never used this module.(never coded

Re: RFC: std.json sucessor

2014-08-22 Thread matovitch via Digitalmars-d
On Friday, 22 August 2014 at 12:39:08 UTC, Sönke Ludwig wrote: Am 22.08.2014 14:17, schrieb matovitch: Very nice ! I had started (and dropped) a json module based on Algebraic too. So without opDispatch you plan to use a syntax like jPerson["age"] = 10 ? You didn't use stdx.d.lexer. Any reason

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 14:47, schrieb matovitch: Ok. I think I remember there was a stdx.d.lexer's Json parser provided as sample. I see, so you just have to write your own number/string parsing routines: https://github.com/Hackerpilot/lexer-demo/blob/master/jsonlexer.d

Is there any preprocessor scripting language?

2014-08-22 Thread MarisaLovesUsAll via Digitalmars-d
I just want to write something like this: #ololo script foreach(child; findAllChildrens()) { child.insert( static void doABarrelRoll() { } ); } #end Templates/mixins is not enough for me... maybe because of hands.dll error :)

Re: RFC: std.json sucessor

2014-08-22 Thread matovitch via Digitalmars-d
On Friday, 22 August 2014 at 13:00:19 UTC, Sönke Ludwig wrote: Am 22.08.2014 14:47, schrieb matovitch: Ok. I think I remember there was a stdx.d.lexer's Json parser provided as sample. I see, so you just have to write your own number/string parsing routines: https://github.com/Hackerpilot/

Re: Is there any preprocessor scripting language?

2014-08-22 Thread Kagamin via Digitalmars-d
You can try D parsing libraries: http://forum.dlang.org/thread/jqwvudiwgiuprqcua...@forum.dlang.org they're believed to enable writing refactoring scripts.

Re: Is there any preprocessor scripting language?

2014-08-22 Thread Kagamin via Digitalmars-d
Example: import std.lexer; import std.d.lexer; import std.array; import std.stdio; void main(string[] args) { File input = File(args[1]); File output = args.length > 2 ? File(args[2]) : stdout; ubyte[] inputBytes = uninitializedArray!(ubyte[])(input.size); input.r

Is there a native function to detect if file is UTF encoding?

2014-08-22 Thread MacAsm via Digitalmars-d
To call decode() from std.encoding I need to make sure it is an UTF (may ne ASCII too) otherwise is will skyp over ASCII values. Is there any D native for it or I need to check byte order mark and write one myself?

Re: Some template code that worked in 2.065 is not working in 2.066

2014-08-22 Thread Dicebot via Digitalmars-d
I believe it should work (it is no different from foreach(elem; myLib.Symbols) which works), but there are better experts on such topics hanging around.

Re: Is there a native function to detect if file is UTF encoding?

2014-08-22 Thread Dejan Lekic via Digitalmars-d
On Friday, 22 August 2014 at 13:53:04 UTC, MacAsm wrote: To call decode() from std.encoding I need to make sure it is an UTF (may ne ASCII too) otherwise is will skyp over ASCII values. Is there any D native for it or I need to check byte order mark and write one myself? You may want to take

Re: Automated source translation of C++ to D

2014-08-22 Thread David Gileadi via Digitalmars-d
On 8/22/14 1:29 AM, David Nadlinger wrote: On Friday, 22 August 2014 at 07:48:30 UTC, Daniel Murphy wrote: So no, you can't magically upgrade a project from C++ to D. Hence the name "magicport"? Sorry, could not resist. David It's pronounced "sufficiently advanced technology port" :)

Re: RFC: std.json sucessor

2014-08-22 Thread Ary Borenszweig via Digitalmars-d
On 8/22/14, 3:33 AM, Sönke Ludwig wrote: Am 22.08.2014 02:42, schrieb Ary Borenszweig: Say I have a class Person with name (string) and age (int) with a constructor that receives both. How would I create an instance of a Person from a json with the json stream? Suppose the json is this: {"age"

Re: Is there a native function to detect if file is UTF encoding?

2014-08-22 Thread Kiith-Sa via Digitalmars-d
On Friday, 22 August 2014 at 13:53:04 UTC, MacAsm wrote: To call decode() from std.encoding I need to make sure it is an UTF (may ne ASCII too) otherwise is will skyp over ASCII values. Is there any D native for it or I need to check byte order mark and write one myself? This may be simpler f

Re: Is there any preprocessor scripting language?

2014-08-22 Thread MarisaLovesUsAll via Digitalmars-d
On Friday, 22 August 2014 at 13:33:12 UTC, Kagamin wrote: You can try D parsing libraries: http://forum.dlang.org/thread/jqwvudiwgiuprqcua...@forum.dlang.org they're believed to enable writing refactoring scripts. Thanks a lot! It will be useful.

Re: scope classes mentioned in tutorials, but deprecated

2014-08-22 Thread Jacob Carlborg via Digitalmars-d
On 2014-08-22 10:37, Daniel Murphy wrote: It's listed as 'future', so it's not actually deprecated. Everyone is treating it as deprecated. While DDMD does currently use it extensively, it can be replaced if necessary. I'd much rather see it reinstated along with proper escape checking. Fa

Re: RFC: std.json sucessor

2014-08-22 Thread Jacob Carlborg via Digitalmars-d
On 2014-08-22 00:35, Sönke Ludwig wrote: Following up on the recent "std.jgrandson" thread [1], I've picked up the work (a lot earlier than anticipated) and finished a first version of a loose blend of said std.jgrandson, vibe.data.json and some changes that I had planned for vibe.data.json for a

Re: scope classes mentioned in tutorials, but deprecated

2014-08-22 Thread Gary Willoughby via Digitalmars-d
On Thursday, 21 August 2014 at 18:07:31 UTC, Brad Anderson wrote: On Thursday, 21 August 2014 at 17:55:19 UTC, Timothee Cour via Digitalmars-d wrote: http://dlang.org/cpptod.html#raii mentions scope class and scope variables, which seem deprecated (http://dlang.org/deprecate.html) https://git

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 15:47:51 UTC, Jacob Carlborg wrote: * I think we have talked about this before, when reviewing D lexers. I'm thinking of how to handle invalid data. Is it the best solution to throw an exception? Would it be possible to return an error token and have the client deci

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 17:47, schrieb Jacob Carlborg: On 2014-08-22 00:35, Sönke Ludwig wrote: Following up on the recent "std.jgrandson" thread [1], I've picked up the work (a lot earlier than anticipated) and finished a first version of a loose blend of said std.jgrandson, vibe.data.json and some chang

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 16:53, schrieb Ary Borenszweig: On 8/22/14, 3:33 AM, Sönke Ludwig wrote: Without a serialization framework it would in theory work like this: JSONValue v = parseJSON(`{"age": 10, "name": "John"}`); auto p = new Person(v["name"].get!string, v["age"].get!int); unfortunate

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
Some thoughts about the API: 1) Instead of `parseJSONValue` and `lexJSON`, how about static methods `JSON.parse` and `JSON.lex`, or even a module level functions `std.data.json.parse` etc.? The "JSON" part of the name is redundant. 2) Also, `parseJSONValue` and `parseJSONStream` probably don

Re: C++'s std::rotate

2014-08-22 Thread monarch_dodra via Digitalmars-d
On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu wrote: On 8/11/14, 2:11 AM, "Nordlöw" wrote: On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote: bool sliceOf(T)(in T[] whole, in T[] slice) { return whole.ptr <= slice.ptr && whole.ptr + slice.length <= whole.pt

Re: RFC: std.json sucessor

2014-08-22 Thread Christian Manning via Digitalmars-d
It would be nice to have integers treated separately to doubles. I know it makes the number parsing simpler to just treat everything as double, but still, it could be annoying when you expect an integer type. I'd also like to see some benchmarks, particularly against some of the high performa

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 18:15, schrieb "Marc Schütz" ": Some thoughts about the API: 1) Instead of `parseJSONValue` and `lexJSON`, how about static methods `JSON.parse` and `JSON.lex`, or even a module level functions `std.data.json.parse` etc.? The "JSON" part of the name is redundant. For those functi

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have integers treated separately to doubles. I know it makes the number parsing simpler to just treat everything as double, but still, it could be annoying when you expect an integer type. That's how I've done it for vibe.data.

Re: Some template code that worked in 2.065 is not working in 2.066

2014-08-22 Thread Vladimir Panteleev via Digitalmars-d
On Friday, 22 August 2014 at 08:47:23 UTC, Uranuz wrote: In my project I have sort of complicated logic to implement data structure that is somehow similar to std.typecons.Tuple. I can't reproduce it, because I can't locate the source of bug. You could try using DustMite: https://github.com/C

Re: RFC: std.json sucessor

2014-08-22 Thread Ary Borenszweig via Digitalmars-d
On 8/22/14, 1:24 PM, Sönke Ludwig wrote: Am 22.08.2014 16:53, schrieb Ary Borenszweig: On 8/22/14, 3:33 AM, Sönke Ludwig wrote: Without a serialization framework it would in theory work like this: JSONValue v = parseJSON(`{"age": 10, "name": "John"}`); auto p = new Person(v["name"].g

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 16:48:44 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:15, schrieb "Marc Schütz" ": Some thoughts about the API: 1) Instead of `parseJSONValue` and `lexJSON`, how about static methods `JSON.parse` and `JSON.lex`, or even a module level functions `std.data.json.parse`

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have integers treated separately to doubles. I know it makes the number parsing simpler to just treat everything as double, but still, it could be annoying when you

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 19:24, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:48:44 UTC, Sönke Ludwig wrote: Actually they take exactly the same parameters and just differ in their return value. It would be more descriptive to name them parseAsJSONValue and parseAsJSONStream - or maybe parseJSO

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have integers treated separately to doubles. I know it makes the number parsing simpler to just treat everything as do

Yet another victory for D

2014-08-22 Thread H. S. Teoh via Digitalmars-d
A friend of mine stumbled across this today: http://tomerfiliba.com/blog/dlang/ Rejoice! :-) T -- Why waste time reinventing the wheel, when you could be reinventing the engine? -- Damian Conway

Re: Yet another victory for D

2014-08-22 Thread Brad Anderson via Digitalmars-d
On Friday, 22 August 2014 at 17:54:36 UTC, H. S. Teoh via Digitalmars-d wrote: A friend of mine stumbled across this today: http://tomerfiliba.com/blog/dlang/ Rejoice! :-) T There's a fairly active conversation going on about this article on Hacker News currently. https://news.yc

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 17:35:20 UTC, Sönke Ludwig wrote: ... why not use exactly the same convention then? => `parse!JSONValue` Would be nice to have a "pluggable" API where you just need to specify the type in a factory method to choose the input format. Then there could be `parse!BSO

Re: Yet another victory for D

2014-08-22 Thread Dicebot via Digitalmars-d
On Friday, 22 August 2014 at 17:54:36 UTC, H. S. Teoh via Digitalmars-d wrote: A friend of mine stumbled across this today: http://tomerfiliba.com/blog/dlang/ Rejoice! :-) T http://forum.dlang.org/post/qycdbardacyhvabyq...@forum.dlang.org

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 17:45:03 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have integers treated separately to doubles. I know it

Re: Yet another victory for D

2014-08-22 Thread Adam D. Ruppe via Digitalmars-d
I got this FB chatted to me from an old programmer friend too yesterday who has never used D himself but knows I do. It seems to be getting somewhat broad exposure.

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/21/2014 3:35 PM, Sönke Ludwig wrote: Destroy away! ;) Thanks for taking this on! This is valuable work. On to destruction! I'm looking at: http://s-ludwig.github.io/std_data_json/stdx/data/json/lexer/lexJSON.html I anticipate this will be used a LOT and in very high speed demanding app

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 19:57, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 17:35:20 UTC, Sönke Ludwig wrote: ... why not use exactly the same convention then? => `parse!JSONValue` Would be nice to have a "pluggable" API where you just need to specify the type in a factory method to choose the i

Re: Yet another victory for D

2014-08-22 Thread H. S. Teoh via Digitalmars-d
On Fri, Aug 22, 2014 at 05:55:03PM +, Dicebot via Digitalmars-d wrote: [...] > http://forum.dlang.org/post/qycdbardacyhvabyq...@forum.dlang.org On Fri, Aug 22, 2014 at 05:56:12PM +, Brad Anderson via Digitalmars-d wrote: [...] > There's a fairly active conversation going on about this arti

Re: Yet another victory for D

2014-08-22 Thread H. S. Teoh via Digitalmars-d
On Fri, Aug 22, 2014 at 06:05:03PM +, Adam D. Ruppe via Digitalmars-d wrote: > I got this FB chatted to me from an old programmer friend too > yesterday who has never used D himself but knows I do. It seems to be > getting somewhat broad exposure. Ah, that would explain why this particular fri

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 20:01, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 17:45:03 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have in

Re: const after initialization / pointers, references and values

2014-08-22 Thread Vicente via Digitalmars-d
First of all thanks for your replies, they are useful. @Philippe: A pure function is ok for initializing "default_nodes" but not for "nodes" because a pure function can't read a file. The "static this" has the problem it needs know the initializer at compile time but I wanted to choose the init

Re: RFC: std.json sucessor

2014-08-22 Thread via Digitalmars-d
On Friday, 22 August 2014 at 18:08:34 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:57, schrieb "Marc Schütz" ": The easiest and cleanest way would be to add a function in std.data.json: auto parse(Target, Source)(Source input) if(is(Target == JSONValue)) { return ...;

Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Apparently there is evidence that unused variables in C-like languages correlate with bugs: https://kev.inburke.com/slides/errors/#error-correlations One problem with ruling out some classes of unused variables (like unused function arguments, unused private module-level variables, unused fun

Re: RFC: std.json sucessor

2014-08-22 Thread Andrej Mitrovic via Digitalmars-d
On 8/22/14, Sönke Ludwig wrote: > Docs: http://s-ludwig.github.io/std_data_json/ This confused me for a solid minute: // Lex a JSON string into a lazy range of tokens auto tokens = lexJSON(`{"name": "Peter", "age": 42}`); with (JSONToken.Kind) { assert(tokens.map!(t => t.kind).equal(

Re: Windows service in D

2014-08-22 Thread Tyler Jensen via Digitalmars-d
Ten years is a long time but perhaps this can help anyone running into this forum thread. https://github.com/duovia/WindowsServiceInD I'm using the Windows API library (source actually) on dsource.org. See link on the github page. I found it difficult to find a complete solution to the proble

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 21:15, schrieb Andrej Mitrovic via Digitalmars-d: On 8/22/14, Sönke Ludwig wrote: Docs: http://s-ludwig.github.io/std_data_json/ This confused me for a solid minute: // Lex a JSON string into a lazy range of tokens auto tokens = lexJSON(`{"name": "Peter", "age": 42}`); with (J

Re: $100 bounty for help with Windows Service code

2014-08-22 Thread Tyler Jensen via Digitalmars-d
On Friday, 22 August 2014 at 09:09:22 UTC, Kagamin wrote: https://github.com/duovia/WindowsServiceInD/blob/master/src/onedge/mysvc.d#L20 these are not necessarily static: it makes sense to have instance fields of shared types too. Yes, Kagamin, you're right. I'll pull those out of shared as th

Re: RFC: std.json sucessor

2014-08-22 Thread Christian Manning via Digitalmars-d
On Friday, 22 August 2014 at 17:45:03 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have integers treated separately to doubles. I know it

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 21:48, schrieb Christian Manning: On Friday, 22 August 2014 at 17:45:03 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2014 18:31, schrieb Christian Manning: It would be nice to have

Re: const after initialization / pointers, references and values

2014-08-22 Thread Vicente via Digitalmars-d
Indeed the ref can be applied to the return type: http://dlang.org/function.html#ref-functions So, does the following code copy any data from "nodes"? If that is the case this solution avoids the "class" storage, avoids pointers and "nodes" is encapsulated as read-only, that's great. The progra

Re: const after initialization / pointers, references and values

2014-08-22 Thread Wyatt via Digitalmars-d
On Friday, 22 August 2014 at 18:21:06 UTC, Vicente wrote: @Wyatt: Certainly ref parameters help a lot, but I'm trying to get a "Node" by returning (a reference to) it. Does the ref keyword apply to the return type? I poked it a bit and came out with this. I _think_ it's working as expected

Re: RFC: std.json sucessor

2014-08-22 Thread John Colvin via Digitalmars-d
On Friday, 22 August 2014 at 20:02:41 UTC, Sönke Ludwig wrote: Am 22.08.2014 21:48, schrieb Christian Manning: On Friday, 22 August 2014 at 17:45:03 UTC, Sönke Ludwig wrote: Am 22.08.2014 19:27, schrieb "Marc Schütz" ": On Friday, 22 August 2014 at 16:56:26 UTC, Sönke Ludwig wrote: Am 22.08.2

Re: Unused variables and bugs

2014-08-22 Thread Brian Schott via Digitalmars-d
On Friday, 22 August 2014 at 19:07:24 UTC, bearophile wrote: Another solution is to leave such tests out of the core compiler, and put them in a lint tool that you run when you think your code is in good shape. https://github.com/Hackerpilot/Dscanner The unused variable and unused parameter c

Re: RFC: std.json sucessor

2014-08-22 Thread Christian Manning via Digitalmars-d
Yes, no decimal point + no exponent would work without overhead to detect integers, but that wouldn't solve the proposed automatic long->double overflow, which is what I meant. My current idea is to default to double and optionally support any of long, BigInt and "Decimal" (BigInt+exponent), wh

Re: const after initialization / pointers, references and values

2014-08-22 Thread Vicente via Digitalmars-d
On Friday, 22 August 2014 at 20:12:39 UTC, Wyatt wrote: I poked it a bit and came out with this. I _think_ it's working as expected: ... auto ref opSlice(){return nodes[];}; ... -Wyatt Assuming it's working as expected, that is exactly what I was looking for! But the following cod

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Brian Schott: The unused variable and unused parameter checks have existed since May. As far as I know it only gives false positives if mixin statements are present. Another interesting feature is similar to -Wsuggest-final-types and -Wsuggest-final-methods. They give warnings when there is

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 20:08, schrieb Walter Bright: On 8/21/2014 3:35 PM, Sönke Ludwig wrote: Destroy away! ;) Thanks for taking this on! This is valuable work. On to destruction! I'm looking at: http://s-ludwig.github.io/std_data_json/stdx/data/json/lexer/lexJSON.html I anticipate this will be use

Re: RFC: std.json sucessor

2014-08-22 Thread Sönke Ludwig via Digitalmars-d
Am 22.08.2014 18:13, schrieb Sönke Ludwig: Am 22.08.2014 17:47, schrieb Jacob Carlborg: * Opening braces should be put on their own line to follow Phobos style guides Will do. * I'm wondering about the assert in lexer.d, line 160. What happens if two invalid tokens after each other occur?

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/22/2014 09:07 PM, bearophile wrote: Apparently there is evidence that unused variables in C-like languages correlate with bugs: https://kev.inburke.com/slides/errors/#error-correlations ... http://xkcd.com/552/

Re: const after initialization / pointers, references and values

2014-08-22 Thread Vicente via Digitalmars-d
If the foreach loop is replaced by: foreach(ref node_ref; np) Then it works like a charm!

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Timon Gehr: http://xkcd.com/552/ What better alternative do you suggest in practice? The only better solution I remember that was used for a language design is the ":" added to Python after some controlled experiments done on users. Relying on experimental correlations (if the analysis is

Re: Unused variables and bugs

2014-08-22 Thread Ary Borenszweig via Digitalmars-d
On 8/22/14, 6:46 PM, bearophile wrote: Currently a group of people are trying to design a language pushing to the extreme the idea of design by committee, it's future a peer reviewed language meant to be used for scientific programming. I've taken a look at its syntax and I was not happy with the

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Ary Borenszweig: What language is that? I don't remember its name, of course. I have just scanned the last few months of the LambdaTheUltimate blog without success. Bye, bearophile

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/23/2014 01:32 AM, Timon Gehr wrote: you seemed to suggest in the OT. OP

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/22/2014 11:46 PM, bearophile wrote: Timon Gehr: http://xkcd.com/552/ ... My point is just that this correlation is not a strong data point supporting putting effort into elimination of unused variables. It is possible that all this will accomplish is that unused variables will no lo

Re: Unused variables and bugs

2014-08-22 Thread Brian Schott via Digitalmars-d
On Friday, 22 August 2014 at 23:32:54 UTC, Timon Gehr wrote: The correlation only indicates that poor code tends to have more unused variables. If one eliminates unused variables just for the sake of eliminating unused variables, code quality will most likely not magically increase. I would a

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/23/2014 02:03 AM, Brian Schott wrote: On Friday, 22 August 2014 at 23:32:54 UTC, Timon Gehr wrote: The correlation only indicates that poor code tends to have more unused variables. If one eliminates unused variables just for the sake of eliminating unused variables, code quality will most

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/22/2014 2:27 PM, Sönke Ludwig wrote: Am 22.08.2014 20:08, schrieb Walter Bright: 1. There's no mention of what will happen if it is passed malformed JSON strings. I presume an exception is thrown. Exceptions are both slow and consume GC memory. I suggest an alternative would be to emit an "

Re: RFC: std.json sucessor

2014-08-22 Thread deadalnix via Digitalmars-d
First thank you for your work. std.json is horrible to use right now, so a replacement is more than welcome. I haven't played with your code yet, so I may be asking for somethign that already exists, but did you had a look to jsvar by Adam ? You can find it here: https://github.com/adamdrup

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/22/2014 6:05 PM, Walter Bright wrote: The problem is that it really depends on the use case and on the type of input stream which approach is more efficient (storing the escaped version of a string might require *two* allocations if the input range cannot be sliced and if the decoded string

Re: RFC: std.json sucessor

2014-08-22 Thread ketmar via Digitalmars-d
On Sat, 23 Aug 2014 02:23:25 + deadalnix via Digitalmars-d wrote: > I haven't played with your code yet, so I may be asking for > somethign that already exists, but did you had a look to jsvar by > Adam ? jsvar using opDispatch, and Sönke wrote: > - No opDispatch() for JSONValue - this ha

Re: Unused variables and bugs

2014-08-22 Thread ketmar via Digitalmars-d
On Fri, 22 Aug 2014 21:46:44 + bearophile via Digitalmars-d wrote: > What better alternative do you suggest in practice? don't declare unused variables. really, this is extremely easy. my 15+ years of expirience in writing projects of different scale shows that good decomposition, code archit

Re: Unused variables and bugs

2014-08-22 Thread via Digitalmars-d
On Saturday, 23 August 2014 at 02:48:15 UTC, ketmar via Digitalmars-d wrote: don't declare unused variables. really, this is extremely easy. my 15+ years of expirience in writing projects of different scale What about: - versioning - debugging (commenting out debugging code) - virtual functio

Re: RFC: std.json sucessor

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 02:30:23 UTC, Walter Bright wrote: Another possibility is to have the user pass in a resizeable buffer which then will be used to store the strings in as necessary. One example is std.internal.scopebuffer. The nice thing about that is the user can use the stack

Re: Unused variables and bugs

2014-08-22 Thread ketmar via Digitalmars-d
On Sat, 23 Aug 2014 03:50:13 + via Digitalmars-d wrote: > - versioning refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to this GCC extension. > - debugging (commenting out debugging code) why comment it out? if (debug_enabled) i

Re: Unused variables and bugs

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 04:07:58 UTC, ketmar via Digitalmars-d wrote: On Sat, 23 Aug 2014 03:50:13 + via Digitalmars-d wrote: - versioning refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to this GCC extension. Won't

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/22/2014 9:01 PM, Ola Fosheim Gr wrote: On Saturday, 23 August 2014 at 02:30:23 UTC, Walter Bright wrote: One example is std.internal.scopebuffer. The nice thing about that is the user can use the stack for the storage, which works out to be very, very fast. Does this mean that D is gettin

Re: RFC: std.json sucessor

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 04:36:34 UTC, Walter Bright wrote: On 8/22/2014 9:01 PM, Ola Fosheim Gr wrote: Does this mean that D is getting resizable stack allocations in lower stack frames? That has a lot of implications for code gen. scopebuffer does not require resizeable stack allocati

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/22/2014 9:48 PM, Ola Fosheim Gr wrote: On Saturday, 23 August 2014 at 04:36:34 UTC, Walter Bright wrote: On 8/22/2014 9:01 PM, Ola Fosheim Gr wrote: Does this mean that D is getting resizable stack allocations in lower stack frames? That has a lot of implications for code gen. scopebuffe

Re: RFC: std.json sucessor

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 05:28:55 UTC, Walter Bright wrote: On 8/22/2014 9:48 PM, Ola Fosheim Gr wrote: On Saturday, 23 August 2014 at 04:36:34 UTC, Walter Bright wrote: On 8/22/2014 9:01 PM, Ola Fosheim Gr wrote: Does this mean that D is getting resizable stack allocations in lower stac

Re: RFC: std.json sucessor

2014-08-22 Thread Walter Bright via Digitalmars-d
On 8/22/2014 11:25 PM, Ola Fosheim Gr wrote: On Saturday, 23 August 2014 at 05:28:55 UTC, Walter Bright wrote: On 8/22/2014 9:48 PM, Ola Fosheim Gr wrote: On Saturday, 23 August 2014 at 04:36:34 UTC, Walter Bright wrote: On 8/22/2014 9:01 PM, Ola Fosheim Gr wrote: Does this mean that D is get

Re: RFC: std.json sucessor

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 06:41:11 UTC, Walter Bright wrote: Scopebuffer is extensively used in Warp, and works very well. The "hole" in the stack is not a significant problem. Well, on a webserver you don't want to push out the caches for no good reason. You can always implement your o