Re: Review: std.msgpack

2010-06-20 Thread Masahiro Nakagawa
On Sun, 20 Jun 2010 02:08:07 +0900, Robert Jacques wrote: On Sat, 19 Jun 2010 00:02:28 -0400, Masahiro Nakagawa wrote: mp_Object is based on std.json.JSONValue. Variant can't have mp_pack method. Hmm..., I check Variant again. Well, std.json is an incomplete, alpha library that's buggy

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread BCS
Hello Andrei, On 06/20/2010 09:00 PM, bearophile wrote: Michel Fortin: But what about the "case 1: ... case 10:" syntax? switch (x) { case 1: .. case 10: case 22: .. case 32: case 52, 64: doSomething(); break; default: whatever(); break; } Sorry, in my first answer I have a bit partially m

Re: enforce()?

2010-06-20 Thread BCS
Hello Leandro, If the DLL has a bug, it will explode anyways. A DLL can work just fine (a.k.a. not explode) and still return garbage as long as it never depends on not seeing the kind of garbage it's producing. Say for instance it's written in D and returns a string with a missing \0 as a c

Re: enforce()?

2010-06-20 Thread Leandro Lucarella
Walter Bright, el 20 de junio a las 19:32 me escribiste: > Leandro Lucarella wrote: > >Why will you assume I'm so dumb that I won't use your > >interface correctly? > > Windows has had major legacy compatibility issues because critical > third party applications misused the APIs. > > People *will

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 09:00 PM, bearophile wrote: Michel Fortin: But what about the "case 1: ... case 10:" syntax? switch (x) { case 1: .. case 10: case 22: .. case 32: case 52, 64: doSomething(); br

Re: enforce()?

2010-06-20 Thread Walter Bright
Leandro Lucarella wrote: Why will you assume I'm so dumb that I won't use your interface correctly? Windows has had major legacy compatibility issues because critical third party applications misused the APIs. People *will* misuse your API, and you will get blamed for it. It's unfair, but t

Re: enforce()?

2010-06-20 Thread Leandro Lucarella
Walter Bright, el 20 de junio a las 17:40 me escribiste: > Vladimir Panteleev wrote: > >On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright > > wrote: > > > >>An input to a dll is user input, and should be validated (for > >>the sake of security, and other reasons). Validating it is not > >>debugging

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Michel Fortin: > But what about the "case 1: ... case 10:" syntax? > > switch (x) { > case 1: .. case 10: > case 22: .. case 32: > case 52, 64: > doSomething(); > break; > default: >

Re: enforce()?

2010-06-20 Thread BCS
Hello Vladimir, On Mon, 21 Jun 2010 03:02:53 +0300, BCS wrote: import my.dll; void fn() { auto data = get.userUncheckedInput(); my.dll.doSomething(data); // if doSomething dosn't check it's inputs, then this can cause a security flaw } Yes that's your dll's user's fault but adding the checks

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Michel Fortin: > But what about the "case 1: ... case 10:" syntax? You are right, I think we have to make an exception on this then, and consider that range a single entity. (You have just found an example why a conceptually messed up syntax (like that ranged one) always comes to bite us in the

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Michel Fortin
On 2010-06-20 19:42:49 -0400, bearophile said: I think he means every case. Sometimes a small change, even if seems a little less handy, is useful. Can't you write code like this, that also looks better to me? import std.stdio: writeln; void doSomething() { writeln("doSomething"); } void wha

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Sean Kelly: > As long as there's a way to enumerate case labels I don't really care what > the syntax is. That would be more than fine with me. Good (note that the code I have written is already correct D syntax) :-) Bye, bearophile

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Sean Kelly
bearophile Wrote: > Sean Kelly: > > You mean every label that is followed by a statement, correct? This is a > > common idiom that I wouldn't want to change: > > > > switch (x) { > > case 1: case 2: case 3: case 4: > > doSomething(); > > break; > > default: > > whatever(); > > } >

Re: A web server with D

2010-06-20 Thread sybrandy
1) What do I need to know in order to develop a web server, generally? A good starting point would be taking a look at current web servers and seeing what they do well etc. Apache httpd is the most widely used one which would be a good starting point, particularly feature wise, but it's also wor

Re: enforce()?

2010-06-20 Thread Vladimir Panteleev
On Mon, 21 Jun 2010 03:40:48 +0300, Walter Bright wrote: Vladimir Panteleev wrote: On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright wrote: An input to a dll is user input, and should be validated (for the sake of security, and other reasons). Validating it is not debugging. I don't u

Re: enforce()?

2010-06-20 Thread Vladimir Panteleev
On Mon, 21 Jun 2010 03:02:53 +0300, BCS wrote: import my.dll; void fn() { auto data = get.userUncheckedInput(); my.dll.doSomething(data); // if doSomething dosn't check it's inputs, then this can cause a security flaw } Yes that's your dll's user's fault but adding the checks solve

Re: enforce()?

2010-06-20 Thread Walter Bright
Vladimir Panteleev wrote: On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright wrote: An input to a dll is user input, and should be validated (for the sake of security, and other reasons). Validating it is not debugging. I don't understand why you're saying this. Security checks in DLL funct

Re: enforce()?

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 06:18 PM, Vladimir Panteleev wrote: On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright wrote: An input to a dll is user input, and should be validated (for the sake of security, and other reasons). Validating it is not debugging. I don't understand why you're saying this. Securi

Re: enforce()?

2010-06-20 Thread BCS
Hello Vladimir, On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright wrote: An input to a dll is user input, and should be validated (for the sake of security, and other reasons). Validating it is not debugging. I don't understand why you're saying this. Security checks in DLL functions are p

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Sean Kelly: > You mean every label that is followed by a statement, correct? This is a > common idiom that I wouldn't want to change: > > switch (x) { > case 1: case 2: case 3: case 4: > doSomething(); > break; > default: > whatever(); > } I think he means every case. Sometimes a sm

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Sean Kelly
Andrei Alexandrescu Wrote: > On 06/19/2010 06:58 AM, Don wrote: > > Andrei Alexandrescu wrote: > >> Don wrote: > >> [snip] > >>> Or is too late to break backwards compatibility with B ? > >> > >> We can and should do it. It won't impact TDPL adversely. > > > > Excellent! I'll make a patch for it w

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Andrei Alexandrescu: > He also agreed to give more thought to the restriction of forcing every > swich label to be ended with a control flow transfer statement. I hope Walter will express his positive vote about this other little C syntax detail, automatic joining of adjacent strings: http://d.p

Re: enforce()?

2010-06-20 Thread Vladimir Panteleev
On Mon, 21 Jun 2010 00:17:28 +0300, Walter Bright wrote: An input to a dll is user input, and should be validated (for the sake of security, and other reasons). Validating it is not debugging. I don't understand why you're saying this. Security checks in DLL functions are pointless, for

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Andrei Alexandrescu: > Walter just gave the green light, so Don - it's up to you. Probably our awesome Don will be able to do it, sooner or later :-) > He also agreed to give more thought to the restriction of forcing every > swich label to be ended with a control flow transfer statement. Good

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-20 Thread Andrei Alexandrescu
On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. Walter just gave the green light, so Don

Re: Combsort comparison

2010-06-20 Thread bearophile
Lutger: > I get about 30% improvement if the inner loop is rewritten to: > > foreach (i; 0 .. total - gap) // total was already computed by walkLength > { > left.popFront; > right.popFront; > if (binaryFun!less(right.front, left.front)) { > swap(left.front, right.front); >

Re: Combsort comparison

2010-06-20 Thread bearophile
Lutger: > Am I right in thinking this algorithm basically requires random access? Both > the > C++ version and the D version will work for ranges that don't do that, but > the > performance difference won't matter anymore because it is likely crap anyway. I don't think it's crap with a linked

Re: Combsort comparison

2010-06-20 Thread bearophile
Lutger: > I get about 30% improvement if the inner loop is rewritten to: Can you please show me the whole program? Don't show inner loops, everybody on the D newsgroups: let's take the habit of posting runnable code, as done on the Python newsgroups, and not broken cuts. Thank you. Bye, bearop

Re: String Literal Docs

2010-06-20 Thread Alix Pexton
On 20/06/2010 21:37, Ellery Newcomer wrote: On 06/20/2010 03:01 PM, Alix Pexton wrote: On 19/06/2010 21:12, Alix Pexton wrote: I've been sketching some grammar diagrams for D2.0, a little like those on JSON.org, and of course I didn't get far before I ran into something odd. I think I will t

Re: Review: std.msgpack

2010-06-20 Thread Jacob Carlborg
On 2010-06-20 00:34, Michel Fortin wrote: On 2010-06-19 15:52:51 -0400, Jacob Carlborg said: Orange (http://dsource.org/projects/orange/) doesn't have those problems (it probably has other problems). These are some of the features: * It automatically serializes the base classes ... * Serializ

Re: enforce()?

2010-06-20 Thread Walter Bright
Vladimir Panteleev wrote: On Sun, 20 Jun 2010 03:04:31 +0300, Walter Bright wrote: Andrei Alexandrescu wrote: On 06/19/2010 03:55 PM, bearophile wrote: Inside Phobos2 I have counted about 160 usages of the "body" keyword. I think contract programming can be used more often inside Phobos2 (a

Using Classes as the KeyType (from the Docs)

2010-06-20 Thread Andrej Mitrovic
Hi, There's an example in the docs about classes with a keytype which I don't fully understand. Here's the code (taken from http://www.digitalmars.com/d/2.0/arrays.html under "Using Classes as the KeyType"): -- class Foo { int a, b;

Re: String Literal Docs

2010-06-20 Thread Ellery Newcomer
On 06/20/2010 03:01 PM, Alix Pexton wrote: On 19/06/2010 21:12, Alix Pexton wrote: I've been sketching some grammar diagrams for D2.0, a little like those on JSON.org, and of course I didn't get far before I ran into something odd. I think I will take the plunge and base my diagrams on the so

Re: Combsort comparison

2010-06-20 Thread Lutger
> // D #3 version > import std.array: empty, popFront, popFrontN, front; > import std.range: walkLength, isForwardRange, hasSwappableElements; > import std.algorithm: swap, binaryFun; > import std.c.stdlib: malloc; > import std.c.stdio: printf; > debug { > import std.contracts: enforce; > i

Re: String Literal Docs

2010-06-20 Thread Alix Pexton
On 20/06/2010 20:14, Nick Sabalausky wrote: "div0" wrote in message news:hvlok6$1rf...@digitalmars.com... On 20/06/2010 18:55, Nick Sabalausky wrote: "div0" wrote in message news:hvkrsc$2r5...@digitalmars.com... It says multiple of 2, not even number of digits. "multiple of 2" == "even n

Re: String Literal Docs

2010-06-20 Thread Alix Pexton
On 19/06/2010 21:12, Alix Pexton wrote: I've been sketching some grammar diagrams for D2.0, a little like those on JSON.org, and of course I didn't get far before I ran into something odd. I think I will take the plunge and base my diagrams on the source of DMD. After looking at the code in l

Re: Combsort comparison

2010-06-20 Thread Lutger
bearophile wrote: ... > > I don't know if my D #3 code is the best possible using Ranges, maybe there is > a way to use them more efficiently, I have just started using D Ranges. In > this program the left and right "cursors" keep their relative distance, and in > practice the C++ program shows th

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 02:29 PM, Ali Çehreli wrote: Andrei Alexandrescu wrote: > IMHO it's more general if the regexp took the string type as a > parameter. This is because later that is easier generalizable to > accepting a range that's different from an array. Agreed. Given T which may be an immut

Re: A web server with D

2010-06-20 Thread Sean Kelly
Nick Sabalausky Wrote: > "Sean Kelly" wrote in message > > > > Read the HTTP RFC, tear your hair out as you realize that the grammar > > isn't context-free > > Really? It seems so simple (but of course, XML seems really simple at first > glance, too). Have an example? I may have exaggerated

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Ali Çehreli
Andrei Alexandrescu wrote: > IMHO it's more general if the regexp took the string type as a > parameter. This is because later that is easier generalizable to > accepting a range that's different from an array. Agreed. Given T which may be an immutable type, what is the cleanest way of creatin

Re: Custom stack to call C function

2010-06-20 Thread novive2
Moritz Warning Wrote: > Now I need to build up the call stack myself. dmd\src\phobos\std\c\stdio.d contain printf() declaration. it vararg. so, imho, you can declare and call C func with varargs. May be you don't need to construct call stack, but properly declare C func?

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 07:01 AM, Ben Hanson wrote: == Quote from Justin Spahr-Summers (justin.spahrsumm...@gmail.com)'s "string" is actually an alias for "immutable(char)[]" (and similarly for the other string types), so its contents are not modifiable, though its length can be adjusted and contents

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Justin Spahr-Summers
On Sun, 20 Jun 2010 12:01:31 + (UTC), Ben Hanson wrote: > > == Quote from Justin Spahr-Summers (justin.spahrsumm...@gmail.com)'s > > "string" is actually an alias for "immutable(char)[]" (and > similarly for > > the other string types), so its contents are not modifiable, though > its > > le

Re: String Literal Docs

2010-06-20 Thread Nick Sabalausky
"div0" wrote in message news:hvlok6$1rf...@digitalmars.com... > On 20/06/2010 18:55, Nick Sabalausky wrote: >> "div0" wrote in message >> news:hvkrsc$2r5...@digitalmars.com... >>> >>> It says multiple of 2, not even number of digits. >> >> "multiple of 2" == "even number" >> >> "Even" as in "eve

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 12:56 PM, Ali Çehreli wrote: Ben Hanson wrote: == Quote from Justin Spahr-Summers (justin.spahrsumm...@gmail.com)'s "string" is actually an alias for "immutable(char)[]" (and similarly for the other string types), so its contents are not modifiable, though its length can be ad

Re: String Literal Docs

2010-06-20 Thread div0
On 20/06/2010 18:55, Nick Sabalausky wrote: "div0" wrote in message news:hvkrsc$2r5...@digitalmars.com... It says multiple of 2, not even number of digits. "multiple of 2" == "even number" "Even" as in "even vs odd" I also said 'To me that implies'. Please don't take what I said out of c

Re: Where will D be in 2015 in the programming language ecosphere?

2010-06-20 Thread bearophile
Nick Sabalausky: > Then they > can customize it further if they really need to, but the real issue is > getting them to decide to use it in the first place, and I'd be very > surprised if a lot of them would be willing to do *all* of the necessary > adjustments merely to test drive it. A Dlit

Re: Where will D be in 2015 in the programming language ecosphere?

2010-06-20 Thread Nick Sabalausky
"BCS" wrote in message news:a6268ff154f88ccde5b99a63...@news.digitalmars.com... > Hello Walter, > >> BCS wrote: >> >>> Maybe someone should make a DMD-EE ("embedded edition") with a truly >>> minimal runtime and library along with a compiler patched to support >>> it (e.g. no GC, no AA's, no hidd

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Ali Çehreli
Ben Hanson wrote: == Quote from Justin Spahr-Summers (justin.spahrsumm...@gmail.com)'s "string" is actually an alias for "immutable(char)[]" (and similarly for the other string types), so its contents are not modifiable, though its length can be adjusted and contents appended. If you need to

Re: String Literal Docs

2010-06-20 Thread Nick Sabalausky
"div0" wrote in message news:hvkrsc$2r5...@digitalmars.com... > > It says multiple of 2, not even number of digits. "multiple of 2" == "even number" "Even" as in "even vs odd" > > Yeah, hex strings should probably have the type ubyte[] > > If you using them to put arbitrary binary in your prog

Re: A web server with D

2010-06-20 Thread Nick Sabalausky
"Sean Kelly" wrote in message news:hvlf5u$18a...@digitalmars.com... > Mengu Wrote: > >> Hi, >> >> I have been interested in and learning D for a while and currently >> developing >> a web development IDE with it. I can say that I have a middle level >> knowledge >> that I have been trying to in

Re: A web server with D

2010-06-20 Thread Sean Kelly
Mengu Wrote: > Hi, > > I have been interested in and learning D for a while and currently developing > a web development IDE with it. I can say that I have a middle level knowledge > that I have been trying to increase. Anyway. I want to develop a web server > for Python and Ruby web applications

Combsort comparison

2010-06-20 Thread bearophile
I have translated another small Python/C++ program to D, this is performs the combsort: http://en.wikipedia.org/wiki/Combsort The original code comes from Wikipedia and the rosettacode site. This is a Python version, the algorithm is very simple: def swap(alist, i, j): alist[i], alist[j] =

Re: Signed word lengths and indexes

2010-06-20 Thread BCS
Hello Don, Simen kjaeraas wrote: BCS wrote: I still haven't seen anyone address how typeof(a>>>b) == typeof(a) breaks c code when a>>>b isn't legal c to begin with. It doesn't, of course. However, it is desirable to have similar rules for similar operations, like >> and >>>. Which is wh

Re: Where will D be in 2015 in the programming language ecosphere?

2010-06-20 Thread BCS
Hello Walter, BCS wrote: Hello dsimcha, For the lower-level systems programming case, the requirement for a runtime (even if it's a fairly lightweight one) and the lack of fine control over things like binary size (due to templates, etc.) will limit usefulness. Yes, these problems can be wo

Re: Improving std.regex(p)

2010-06-20 Thread BCS
Hello Ellery, On 06/19/2010 10:55 PM, BCS wrote: Hello Nick, "BCS" wrote in message news:a6268ff154ca8ccddf1ef51e...@news.digitalmars.com... Hello Ellery, Generally I think D's CT capabilities have a way to go yet before this would be worth tackling. E.g. how do you build a parse tree if

Re: A web server with D

2010-06-20 Thread Robert Clipsham
On 20/06/10 12:54, Mengu wrote: Hi, I have been interested in and learning D for a while and currently developing a web development IDE with it. I can say that I have a middle level knowledge that I have been trying to increase. Anyway. I want to develop a web server for Python and Ruby web appl

Re: main.d(61): Error: temp_[i_] isn't mutable

2010-06-20 Thread Ben Hanson
== Quote from Justin Spahr-Summers (justin.spahrsumm...@gmail.com)'s > "string" is actually an alias for "immutable(char)[]" (and similarly for > the other string types), so its contents are not modifiable, though its > length can be adjusted and contents appended. If you need to be able to > modif

A web server with D

2010-06-20 Thread Mengu
Hi, I have been interested in and learning D for a while and currently developing a web development IDE with it. I can say that I have a middle level knowledge that I have been trying to increase. Anyway. I want to develop a web server for Python and Ruby web applications some months later from no

Custom stack to call C function

2010-06-20 Thread Moritz Warning
Hi, I need to call a C function from D. No problem so far, but here is the catch: The function signature is only known at runtime. There is the void* pointer to the C-function and void* pointers to the argument values + value size. Now I need to build up the call stack myself. How can it be done

Re: String Literal Docs

2010-06-20 Thread div0
On 20/06/2010 11:03, Alix Pexton wrote: On 20/06/2010 01:09, div0 wrote: On 19/06/2010 23:17, Ellery Newcomer wrote: All I can say is auto w = x"dead beef"w; results in Error: invalid UTF-8 sequence on dmd 2.047 Then you've found a bug, you know what to do: http://d.puremagic.com/issues

Re: String Literal Docs

2010-06-20 Thread Alix Pexton
On 19/06/2010 22:16, Ellery Newcomer wrote: On 06/19/2010 03:12 PM, Alix Pexton wrote: I also noticed a bug in the tracker related to initial underscores in float literals, if the diagrams start getting to puzzling I might look into that ^^ What what? Bug 2734 is the underscores in floats i

Re: String Literal Docs

2010-06-20 Thread Alix Pexton
On 20/06/2010 01:09, div0 wrote: On 19/06/2010 23:17, Ellery Newcomer wrote: All I can say is auto w = x"dead beef"w; results in Error: invalid UTF-8 sequence on dmd 2.047 Then you've found a bug, you know what to do: http://d.puremagic.com/issues/ Hmn, that would seem to indicate to

Re: Improving std.regex(p)

2010-06-20 Thread Don
Ellery Newcomer wrote: On 06/19/2010 10:55 PM, BCS wrote: Hello Nick, "BCS" wrote in message news:a6268ff154ca8ccddf1ef51e...@news.digitalmars.com... Hello Ellery, Generally I think D's CT capabilities have a way to go yet before this would be worth tackling. E.g. how do you build a parse

Re: Signed word lengths and indexes

2010-06-20 Thread Don
Simen kjaeraas wrote: BCS wrote: I still haven't seen anyone address how typeof(a>>>b) == typeof(a) breaks c code when a>>>b isn't legal c to begin with. It doesn't, of course. However, it is desirable to have similar rules for similar operations, like >> and >>>. Which is why I said that i

Re: Where will D be in 2015 in the programming language ecosphere?

2010-06-20 Thread Walter Bright
BCS wrote: Hello dsimcha, For the lower-level systems programming case, the requirement for a runtime (even if it's a fairly lightweight one) and the lack of fine control over things like binary size (due to templates, etc.) will limit usefulness. Yes, these problems can be worked around, but