Re: opDispatch, duck typing, and error messages

2011-04-22 Thread spir
On 04/22/2011 03:53 AM, Robert Jacques wrote: On Thu, 21 Apr 2011 18:24:55 -0400, Adam D. Ruppe wrote: [snip] Or, there's a whole new approach: e) Duck typing for ranges in to!() might be a bad idea. Again, remember, a class might legitimately offer a range interface, so it would trigger this

Re: opDispatch, duck typing, and error messages

2011-04-22 Thread spir
On 04/22/2011 01:25 AM, Adam D. Ruppe wrote: bearophile wrote: Maybe exceptions nature should be changed a little so they store __FILE__ and __LINE__ on default (exceptions without this information are kept on request, for optimization purposes). I'd like that. Even with a stack trace, it's

Re: opDispatch, duck typing, and error messages

2011-04-22 Thread spir
On 04/22/2011 12:24 AM, Adam D. Ruppe wrote: I just made an innocent little change to one of my programs, hit compile, and got this vomit: /home/me/d/dmd2/linux/bin/../../src/phobos/std/conv.d(97): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S, T)&& isSomeString!(T)&& isInput

Re: postincrement behaviour (differences between dmd and gdc)

2011-04-20 Thread spir
On 04/20/2011 11:33 AM, Iain Buclaw wrote: This was partially discussed before some time ago - http://www.digitalmars.com/d/archives/digitalmars/D/postincrement_behaviour_differences_between_dmd_and_gdc_47334.html The following statement has different behaviours in dmd and gdc. int x; x = x++;

Re: Hidden argument kind antipattern

2011-04-20 Thread spir
On 04/20/2011 01:53 AM, dsimcha wrote: On 4/19/2011 7:30 PM, spir wrote: And what about requiring "lazy" (and "ref") at the call site; I mean in the long term? I find this very sensible. Denis I wouldn't mind this for "lazy" but would argue heavily again

Re: Hidden argument kind antipattern

2011-04-20 Thread spir
On 04/20/2011 01:42 AM, Kai Meyer wrote: On 04/19/2011 05:18 PM, dsimcha wrote: == Quote from Vladimir Panteleev (vladi...@thecybershadow.net)'s article To elaborate, I mean allowing code which appears to behave surprisingly different from the at-a-glance interpretation, unless the programmer k

Re: Hidden argument kind antipattern

2011-04-19 Thread spir
On 04/20/2011 01:18 AM, dsimcha wrote: == Quote from Vladimir Panteleev (vladi...@thecybershadow.net)'s article To elaborate, I mean allowing code which appears to behave surprisingly different from the at-a-glance interpretation, unless the programmer knows the function's signature. I've notice

Re: Hidden argument kind antipattern

2011-04-19 Thread spir
On 04/20/2011 01:09 AM, Vladimir Panteleev wrote: To elaborate, I mean allowing code which appears to behave surprisingly different from the at-a-glance interpretation, unless the programmer knows the function's signature. I've noticed a worrying adoption in D of this "antipattern", which, frankl

Re: lame question

2011-04-18 Thread spir
On 04/18/2011 10:31 AM, %u wrote: Is it necessary free memory allocated for member of structure, like in C? I suppose not (we have gc). Example: struct BITMAP { (...) ubyte[] pixels; } BITMAP* bitmap = new BITMAP; bitmap.pixels = new ubyte[100*100]; (...) // delete bitmap.pixels; //not necessa

Re: LLVM Coding Standards

2011-04-15 Thread spir
On 04/15/2011 01:10 PM, Spacen Jasset wrote: As other posters have pointed out, it seems to me, at least, that having a way to express your model/idea or view of a problem directly is the most useful thing a language can give you. This is my definition of a good language :-) Denis -- _

Re: [OT] Partial-reparsing thory?

2011-04-15 Thread spir
On 04/15/2011 02:40 AM, Nick Sabalausky wrote: "spir" wrote in message news:mailman.3527.1302824019.4748.digitalmar...@puremagic.com... On 04/15/2011 12:51 AM, Nick Sabalausky wrote: Is anyone aware of any (formal or informal) theory/information/research/articles/etc. that's al

Re: [OT] Partial-reparsing thory?

2011-04-14 Thread spir
On 04/15/2011 12:51 AM, Nick Sabalausky wrote: Is anyone aware of any (formal or informal) theory/information/research/articles/etc. that's already been done on the idea of reparsing *part* of an already-parsed source? Either lexing, parsing or both together. Preferably LR, but LL might be helpfu

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 09:10 PM, Steven Schveighoffer wrote: On Thu, 14 Apr 2011 14:57:44 -0400, Andrei Alexandrescu wrote: On 4/14/11 1:26 PM, Steven Schveighoffer wrote: On Thu, 14 Apr 2011 13:54:00 -0400, Andrei Alexandrescu wrote: On 4/14/11 12:26 PM, Steven Schveighoffer wrote: Any particular

Re: Ceylon language

2011-04-14 Thread spir
On 04/14/2011 09:06 PM, bearophile wrote: But I guess optionality could, and should, extend to non-ref types; thus, null > is just a particular case of non-existence. And this would apply especially on > function parameters: > void f (int i?) {...} From C# experience it seems non-ref nu

Re: single-line string?

2011-04-14 Thread spir
On 04/14/2011 07:58 PM, Jesse Phillips wrote: spir Wrote: I would like to know how& how well other editors deal with all of that (especially but not only emacs and vim). Vim's heritage is line based editing. For this reason operations are performed by line and it does processin

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-14 Thread spir
On 04/14/2011 07:58 PM, "Jérôme M. Berger" wrote: spir wrote: Actually, I have never been pleased that func defs (1) look like func calls (2) have an exceptional syntax compared to other definitions. I'd like instead eg: square = function (int n) int {

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 07:09 PM, Andrei Alexandrescu wrote: Applying "let me output something and eye it" at the level of each unit test does not scale because it makes it extremely difficult to identify issues once one test of many produces unexpected output. There are programs (such as "expect") that au

Re: optionally verbose assertions

2011-04-14 Thread spir
On 04/14/2011 06:52 PM, Steven Schveighoffer wrote: A compromise might be to be able to name unit tests, and then run a specific unit test by name on execution only. This allows you to ensure a specific unit test (and specific asserts in that unit test) are running without having to see all the

Re: optionally verbose assertions

2011-04-14 Thread spir
On 04/14/2011 06:35 PM, Daniel Gibson wrote: Am 14.04.2011 17:47, schrieb Steven Schveighoffer: On Thu, 14 Apr 2011 11:28:39 -0400, spir wrote: On 04/14/2011 04:03 PM, Steven Schveighoffer wrote: Sometimes, I worry that my unit tests or asserts aren't running. Every once in a while, I

Re: optionally verbose assertions

2011-04-14 Thread spir
On 04/14/2011 05:47 PM, Steven Schveighoffer wrote: On Thu, 14 Apr 2011 11:28:39 -0400, spir wrote: On 04/14/2011 04:03 PM, Steven Schveighoffer wrote: Sometimes, I worry that my unit tests or asserts aren't running. Every once in a while, I have to change one to fail to make sure that

Re: single-line string?

2011-04-14 Thread spir
On 04/14/2011 05:03 PM, Andrej Mitrovic wrote: Some editors automatically add the closing double quote, which pretty much eliminates this problem. For example: step1: string s = |<- caret step2: string s = "|<- caret step3: string s = "|"<- editor automatically adds the ending quote step4: strin

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 04:24 PM, Andrei Alexandrescu wrote: On 4/14/11 7:25 AM, spir wrote: On 04/14/2011 03:04 AM, Adam D. Ruppe wrote: bearophile wrote: > This is a problem. Unittest code is not meant to produce an output, > while online snippets to try are meant to nearly always pro

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 04:22 PM, Andrei Alexandrescu wrote: On 4/14/11 6:52 AM, spir wrote: On 04/14/2011 01:11 AM, bearophile wrote: * Since most of them don't actually output anything, the program > now detects output.length == 0 and says "Program run > successfully." upon co

optionally verbose assertions

2011-04-14 Thread spir
On 04/14/2011 04:03 PM, Steven Schveighoffer wrote: Sometimes, I worry that my unit tests or asserts aren't running. Every once in a while, I have to change one to fail to make sure that code is compiling (this is especially true when I'm doing version statements or templates). It would be nice

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 03:50 PM, David Nadlinger wrote: On 4/14/11 3:44 PM, spir wrote: On 04/14/2011 02:40 PM, David Nadlinger wrote: On 4/14/11 2:26 PM, spir wrote: Not having any imports makes for a faster compile, too. ... and helps in having safe sandboxes. In which way exactly do I need an

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 04:21 PM, Andrei Alexandrescu wrote: On 4/14/11 6:49 AM, spir wrote: On 04/14/2011 11:30 AM, Jacob Carlborg wrote: On 2011-04-13 22:38, Andrei Alexandrescu wrote: I'm quite excited about the new look of std (right now realized only by http://d-programming-language.org/p

single-line string?

2011-04-14 Thread spir
Hello, This may be a feature request for a single-line string syntactic form --if ever others are annoyed as well, see below. One possible form may be: str = s"abc"; I have myself long found it stupid to separate single- and multi-line string, since there is no formal reason for that. But

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 02:40 PM, David Nadlinger wrote: On 4/14/11 2:26 PM, spir wrote: Not having any imports makes for a faster compile, too. ... and helps in having safe sandboxes. In which way exactly do I need an import to write »extern(C) int system(in char *); system(…);«? Did I write &qu

Re: Ceylon language

2011-04-14 Thread spir
On 04/13/2011 07:06 PM, bearophile wrote: Kagamin: > How will it work on this code? > > String? name = process.args.first; > myLibCustomEnforce(exists name); > writeLine("Hello " name "!"); If you want to implement the feature well, then the compiler has to manage a bit of type state too.

Re: Ceylon language

2011-04-14 Thread spir
On 04/13/2011 02:34 PM, bearophile wrote: - Ceylon does not support method overloading (or any other kind of overloading). How to survive? Named args and default values somewhat mitigate this lack, but still... I read (somewhere) this only for /operator/ overloading. -

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 06:32 AM, Walter Bright wrote: On 4/13/2011 6:04 PM, Adam D. Ruppe wrote: I don't know - I like the approach Andrei took in the docs, writing a series of true assertations. assert(sort([4, 2]) == [2, 4]); does look pretty neat. I guess the alternative is: writeln(sort[4, 2]); //

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 03:04 AM, Adam D. Ruppe wrote: bearophile wrote: > This is a problem. Unittest code is not meant to produce an output, > while online snippets to try are meant to nearly always produce a > meaningful output. I don't know - I like the approach Andrei took in the docs, writing a

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 02:56 AM, bearophile wrote: Andrei: I disagree. I find examples that use assert() much clearer than examples that print something to the console and then explain in a comment what you ought to be seeing. I don't understand why you say that. Isn't learning and understanding based

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 02:56 AM, bearophile wrote: Andrei: > I disagree. I find examples that use assert() much clearer than examples > that print something to the console and then explain in a comment what > you ought to be seeing. I don't understand why you say that. Isn't learning and understandi

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 02:51 AM, Adam D. Ruppe wrote: Andrej Mitrovic wrote: I've always wondered.. how do you detect malicious D code? It doesn't. What it does is use the ulimit feature in linux to limit the resources available to each process so they can't do anything. Try it: int[] a; a.length = 5

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 01:11 AM, bearophile wrote: * Since most of them don't actually output anything, the program > now detects output.length == 0 and says "Program run > successfully." upon completion to give some feedback. This is a problem. Unittest code is not meant to produce an output, wh

Re: "Try it now"

2011-04-14 Thread spir
On 04/14/2011 11:30 AM, Jacob Carlborg wrote: On 2011-04-13 22:38, Andrei Alexandrescu wrote: I'm quite excited about the new look of std (right now realized only by http://d-programming-language.org/phobos-prerelease/std_algorithm.html). Here's a suggestion on how we could improve it more. Ada

Re: "Try it now"

2011-04-14 Thread spir
On 04/13/2011 10:54 PM, Adam D. Ruppe wrote: Andrei wrote: Adam wrote an in-browser evaluator for D programs. These, when presented on the homepage with "hello, world" in them are of limited usefulness. However, a personalized "try it now" button present for _each_ artifact in an std module woul

unittest{...} as "free" code bolck

2011-04-14 Thread spir
On 04/13/2011 10:38 PM, Andrei Alexandrescu wrote: Similarly, it would be great if next to e.g. http://d-programming-language.org/phobos-prerelease/std_algorithm.html#setUnion there would be a "Try it now" button. Clicking on that button would open an overlay with an edit window. The edit window

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-14 Thread spir
On 04/13/2011 11:44 PM, Andrei Alexandrescu wrote: On 4/13/11 4:17 PM, "Jérôme M. Berger" wrote: Well, standard (printed) typographic practices put spaces outside the parenthesis and none inside. And as opposed to a lot of typographic rules, that one is a constant across languages and variants.

Re: D Tools Special Interest Group (SIG)

2011-04-13 Thread spir
On 04/13/2011 12:04 AM, Sean Kelly wrote: On Apr 1, 2011, at 11:53 AM, Bruno Medeiros wrote: On 22/03/2011 23:41, Jonas Drewsen wrote: Hi, It seems that every now and then a discussion about build tools or D package management pops up in this group. Many people on this list have a huge amount

Re: Temporarily disable all purity for debug prints

2011-04-12 Thread spir
On 04/12/2011 09:54 PM, Steven Schveighoffer wrote: On Tue, 12 Apr 2011 15:48:33 -0400, bearophile wrote: Walter: pure void foo() { debug writeln("in foo()"); } Simple and effective. Very simple designs are sometimes the mark of the genius. But isn't your idea able to lead to debug code t

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-12 Thread spir
On 04/12/2011 10:08 PM, Nick Sabalausky wrote: ""Jérôme M. Berger"" wrote in message news:io2396$1nuo$1...@digitalmars.com... spir wrote: A drawback is one cannot directly have different indent levels, for instance to indent collection contents more, or less, than bloc

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 08:19 PM, "Jérôme M. Berger" wrote: spir wrote: On 04/12/2011 04:18 AM, dsimcha wrote: On 4/11/2011 9:55 PM, Daniel Gibson wrote: Doesn't mysql even have some retarded restriction like "it's GPL but may not be used for commercial purposes so buy mysql if

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 04:01 PM, Fawzi Mohamed wrote: For my personal libs/programs I fully agree with spir: 1) attribution is a very light burden 2) it is nice, and somehow the right thing to do 3) it gives back at least a bit of advertisement to the stuff *you can use freely* For those reasons I did

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 03:02 PM, Daniel Gibson wrote: D is not a Linux/FOSS-only language, but also to be used on Windows and for proprietary software. And especially for Windows it's common to distribute software (especially freeware and shareware ) just as the self-contained binary. Windows apps have

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 11:55 AM, Daniel Gibson wrote: Am 12.04.2011 11:34, schrieb spir: On 04/12/2011 04:06 AM, Daniel Gibson wrote: Well I'd always use PostgreSQL instead of MySQL when having the choice, but 1. often MySQL needs to be used because it's already there 2. PostgreSQL uses the B

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 12:45 PM, Nick Sabalausky wrote: (depending, of course, on the incomprehensible details of the GPL) GPL is just one sample. And I don't get your insistance on "incomprehensible details": as if you did not know *all* devices and all commercial software you have ever bought come w

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 10:43 AM, Jacob Carlborg wrote: On 2011-04-12 03:45, Daniel Gibson wrote: Am 11.04.2011 19:05, schrieb Russel Winder: On Mon, 2011-04-11 at 15:39 +, Adam D. Ruppe wrote: [ . . . ] fine, but a standard library is distributed with D programs. LGPL requires you to send source wh

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 01:31 PM, Nick Sabalausky wrote: And most of all, I really think the chances of getting irreprably screwed over like that by putting a program out as BSD instead of GPL are small enough to just not be worth worrying about. Isn't BSD license also unwelcome into Phobos? (/That/ issu

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 12:24 PM, Nick Sabalausky wrote: "Russel Winder" wrote in message news:mailman.3416.1302591172.4748.digitalmar...@puremagic.com... Personally I find licences such as BSD, MIT, ASL, etc. ones to avoid since they allow organizations to take software, sell it for profit and return a

Re: Anyone interested in simpleaudio.d too?

2011-04-12 Thread spir
On 04/12/2011 06:30 AM, Adam D. Ruppe wrote: I just dug up my old wav.d and quickly added wav.play() support to it for both Windows and Linux. Now, this is sucky D1 code, but hey, it works, and it's short. If there's interest, I can port to D2 and add some range support to it and see about fleshi

Re: LLVM Coding Standards

2011-04-12 Thread spir
On 04/12/2011 03:15 AM, Daniel Gibson wrote: While I am on the subject, I've *always* thought major languages have > poor loop constructs: > > > (A) > > for (;;) > { > std::getline(is, line); > if (line.size() == 0) > break; > ...some things... > } > (...) > >

Re: LLVM Coding Standards

2011-04-12 Thread spir
On 04/12/2011 03:08 AM, Walter Bright wrote: On 4/11/2011 2:03 PM, bearophile wrote: it's very far from the C-style hairy code of DMD I'm overcompensating for being bald. Unfortunately, beeing bald does not seem to always help. While I'm nearly bald as well, I found the few pieces of dmd an

Re: LLVM Coding Standards

2011-04-12 Thread spir
On 04/12/2011 02:34 AM, Nick Sabalausky wrote: The last few years though, I've been finding that I *never* have any trouble grokking code due to early exits or continue (unless the code is already convoluted anyway). And I've also realized I find code that makes intelligent use of it to be much *

Re: LLVM Coding Standards

2011-04-12 Thread spir
On 04/12/2011 12:31 AM, Spacen Jasset wrote: I think that people like to follow rules, that is as soon as they have internalised them and made them their own. What this means is that they often then follow them to a fault, and you get deeply nested, but "structured" code, where instead you would

Re: [GSOC] Database API draft proposal

2011-04-12 Thread spir
On 04/12/2011 04:15 AM, dsimcha wrote: I think 110% that SQLite should be the top priority w.r.t. database stuff. SQLite bindings and a good D API with some dependency inversion so the high-level API can be reused with other database backends would be a great GSoC project, even if nothing involvi

Re: LLVM Coding Standards

2011-04-12 Thread spir
On 04/11/2011 09:58 PM, spir wrote: I'm reading (just for interest) the LLVM Coding Standards at http://llvm.org/docs/CodingStandards.html. Find them very interesting because their purposes are clearly explained. Below sample. I also love their note about n

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 04:18 AM, dsimcha wrote: On 4/11/2011 9:55 PM, Daniel Gibson wrote: Doesn't mysql even have some retarded restriction like "it's GPL but may not be used for commercial purposes so buy mysql if you wanna use it to make money"? According to Wikipedia (http://en.wikipedia.org/wiki/

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 04:06 AM, Daniel Gibson wrote: Well I'd always use PostgreSQL instead of MySQL when having the choice, but 1. often MySQL needs to be used because it's already there 2. PostgreSQL uses the BSD-License which also isn't suitable for Phobos. BTW: I think PHP has a native SQL driver (u

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-12 Thread spir
On 04/12/2011 09:24 AM, Jacob Carlborg wrote: Well, IMO, using spaces for indentation serves no useful purpose. At least tabs actually *mean* alignment and indentation. Spaces don't and never have. Plus, what's the use of being able place the cursor at arbtrary points within the "4 spaces" (or 8

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-12 Thread spir
On 04/12/2011 07:13 AM, Jonathan M Davis wrote: It's true that people occasionally end up inserting tabs in space-only environments, but in my experience, it's fairly rare. It's pretty much a guarantee, however, that _someone_ will insert spaces in an environment where it's supposed to be tabs.

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-12 Thread spir
On 04/12/2011 05:19 AM, Jonathan M Davis wrote: Using only spaces and no tabs avoids the entire issue spaces <--> tabs works as fine Why are programmers so blindly unfair when discussing this point? and is one of the major reasons (if not _the_ major reason) why it is incredibly common for

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-12 Thread spir
On 04/12/2011 05:15 AM, Jonathan M Davis wrote: So, how you format your code matters. Using tabs screws with that unless you're completely consistent, and while a single developer may be consistent, groups of developers rarely are. This is as true in the case of spaces. With the additional issu

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 09:05 AM, Andrew Wiley wrote: On Tue, Apr 12, 2011 at 1:52 AM, Russel Winder wrote: On Mon, 2011-04-11 at 19:47 -0400, Nick Sabalausky wrote: [ . . . ] Regardless, I think we've clearly demonstrated the complete impenetrability of (L)GPL. I've long since given up trying to under

Re: [OT] open-source license issues

2011-04-12 Thread spir
On 04/12/2011 01:47 AM, Nick Sabalausky wrote: "Jonas Drewsen" wrote in message news:invnrn$2pgf$1...@digitalmars.com... On 11/04/11 22.01, Steven Schveighoffer wrote: On Mon, 11 Apr 2011 13:05:24 -0400, Russel Winder wrote: On Mon, 2011-04-11 at 15:39 +, Adam D. Ruppe wrote: [ . . . ]

Re: Temporarily disable all purity for debug prints

2011-04-12 Thread spir
On 04/12/2011 04:05 AM, Nick Sabalausky wrote: As more and more D2 functions become pure in my code and in Phobos, > something like a -disablepure compiler switch (and printf/writeln inside > debug{}) may allow more handy debugging with prints (if the purity is well > managed by the compiler t

Re: Slides about Nemerle

2011-04-11 Thread spir
On 04/11/2011 02:05 PM, bearophile wrote: Simple slides about Nemerle language, derived from C#, so far I have never used Nemerle: http://www.reddit.com/r/programming/comments/gnaop/nemerle_vs_c/ The things I like more are yield (page 20 and 44 of the PDF), some tuple syntax (page 51), pattern

Re: Temporarily disable all purity for debug prints

2011-04-11 Thread spir
On 04/11/2011 11:27 PM, bearophile wrote: From what I am seeing, in a D2 program if I have many (tens or more) pure functions that call to each other, and I want to add (or activate) a printf/writeln inside one (or few) of those functions to debug it, I may need to temporarily comment out the

LLVM Coding Standards

2011-04-11 Thread spir
[slightly OT] Hello, I'm reading (just for interest) the LLVM Coding Standards at http://llvm.org/docs/CodingStandards.html. Find them very interesting because their purposes are clearly explained. Below sample. Denis === sample === Use Early Exits and contin

Re: YesOrNo: useful idiom helper or wanking?

2011-04-11 Thread spir
On 04/11/2011 09:35 PM, Nick Sabalausky wrote: "Andrei Alexandrescu" wrote in message news:inv4rv$1dfl$1...@digitalmars.com... A fair amount of code in std uses this idiom: enum SomeOption { no, yes } void someFunction(...parms..., SomeOption, ...more_parms...) { ... } SomeOption is really a

Re: YesOrNo: useful idiom helper or wanking?

2011-04-11 Thread spir
On 04/11/2011 08:16 PM, KennyTM~ wrote: If the goal of YesOrNo is simply for documentation, why not define it like this? import std.stdio; template YesOrNo(T) if(is(T == enum) && !T.no && T.yes) { alias T YesOrNo; } enum Redraw : bool { no, yes } void drawCircle(YesOrNo!Redraw redraw) {

Re: YesOrNo: useful idiom helper or wanking?

2011-04-11 Thread spir
On 04/11/2011 08:16 PM, KennyTM~ wrote: import std.stdio; template YesOrNo(T) if(is(T == enum) && !T.no && T.yes) { alias T YesOrNo; } enum Redraw : bool { no, yes } void drawCircle(YesOrNo!Redraw redraw) { writeln(cast(bool) redraw); } void main() { drawCircle(Redraw.yes);

Re: YesOrNo: useful idiom helper or wanking?

2011-04-11 Thread spir
On 04/11/2011 07:49 PM, Andrej Mitrovic wrote: Also, I would rather name this template "choice". YesOrNo is far better, by making it clear it's a kind of logical choice / closed question. "Choice" is super vague. Denis -- _ vita es estrany spir.wikidot.com

Re: YesOrNo: useful idiom helper or wanking?

2011-04-11 Thread spir
On 04/11/2011 04:59 PM, Andrej Mitrovic wrote: It looks like an awkward workaround for that feature called named arguments. True, but only for the case of yes/no; in this case only, the bool type provides proper *constants* which *meaning* is obvious. Else, you need an enum anyway, even with

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-11 Thread spir
On 04/11/2011 05:31 PM, Adam D. Ruppe wrote: bearophile: It's a module theoretically meant for Phobos, and the Phobos coding standard are spaces. Yeah, that's all that matters in the end. "When in Rome..." But it's trivial to do a find and replace all before submitting so really, it's just no

Re: std.algorithm for images

2011-04-11 Thread spir
On 04/11/2011 06:09 PM, Adam D. Ruppe wrote: Walter Bright wrote: I don't know much about graphics [...] The irony is neither do I! But, an algorithm is an algorithm so I'm hoping if it can work well for the few I know, we'll have an approach that can work for others too, all written independe

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-11 Thread spir
On 04/11/2011 10:01 AM, Jonathan M Davis wrote: Jonathan M Davis Wrote: > > Personally, I think that it's _horrible_ to use tabs > > Why would one fear tabs? They change depending on your editor settings. That's precisely what they are meant for... unlike space-indentation, tab-indentati

[OT] open-source license issues

2011-04-11 Thread spir
On 04/11/2011 02:45 AM, Adam D. Ruppe wrote: Cliff Hudson wrote: > Have you considered wrapping something like DevIL? I actually didn't consider it; since I already have decent homegrown loaders for a few formats I figured that'd be good enough, for now at least. But, looking now, DevIL is LG

Re: std.algorithm for images

2011-04-11 Thread spir
On 04/11/2011 02:10 AM, Adam D. Ruppe wrote: I'm pretty happy with how simpledisplay.d is turning out, and want to spend some time thinking about the client side images now. I think a nice way to do it would be to go with ranges and templates, like std.algorithm, so things will work across many

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-11 Thread spir
On 04/11/2011 08:13 AM, Jonathan M Davis wrote: They mix tabs and spaces. On some lines, they use spaces and on others they use tabs. Never seen this, not even once. Messing can only happen when one copy-pastes from modules using spaces. Denis -- _ vita es estrany spir.wikido

Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))

2011-04-11 Thread spir
On 04/11/2011 07:51 AM, Jonathan M Davis wrote: the only way that tabs work is if you use them consistently, which in my experience almost never happens. And How so? If you probably set your editor, inconsistency simply cannot happen... The same is true for using spaces, anyway. Denis -- ___

Re: simple display (from: GUI library for D)

2011-04-11 Thread spir
On 04/11/2011 03:54 AM, Adam D. Ruppe wrote: 1. *Please use spaces instead of tabs.* Spaces are the spawn of Satan! I hate them, but when it comes time to submit to phobos, I'll run a find/replace of them so it's consistent with the prevailing style there. Until then though, I'll write it in my

Re: http://lang-index.sourceforge.net/

2011-04-11 Thread spir
On 04/11/2011 08:05 AM, bearophile wrote: Andrej Mitrovic: > I was browsing through that D filter on google, and found this: > http://theinf2.informatik.uni-jena.de/For+Students/Lectures/D+Programming.html > > This must be the second school to teach D that I know of, after I've > heard abo

Re: simple display (from: GUI library for D)

2011-04-10 Thread spir
On 04/10/2011 03:03 AM, Cliff Hudson wrote: One thing to consider, since I was impacted by this when writing a WPF app a while back, is the difference between a 2-Vector and a Point. In particular, Vectors typically have some very useful methods on them, like addition, rotation, transformations,

Re: simple display (from: GUI library for D)

2011-04-10 Thread spir
On 04/10/2011 02:58 AM, Adam D. Ruppe wrote: A note: since I posted last, I changed my mind on something, and bearophile, I rather doubt you'll like it... Before, it was drawRectangle(int x1, int y2, int width, int height); Now, it is drawRectangle(Point upperLeft, Size size); So, at the usage

Re: simple display (from: GUI library for D)

2011-04-10 Thread spir
On 04/09/2011 11:45 PM, Adam D. Ruppe wrote: There's still a handful of little things and a lot of error checking needed, but I'm pretty happy with this as the screen drawing base. It covers all the easy stuff. The hard stuff will be in platform independent images. Anyway, here's the updated si

Re: Is the world coming to an end?

2011-04-09 Thread spir
On 04/09/2011 11:07 AM, Caligo wrote: There is no such thing as base 1 number system. Stop wasting your time. lol! -- _ vita es estrany spir.wikidot.com

Re: simple display (from: GUI library for D)

2011-04-09 Thread spir
On 04/09/2011 06:50 AM, Cliff Hudson wrote: So is the objective to create a windowing library, or a drawing library for (for example) games? The two are rather different - though you can build a windowing library on top of a drawing library, doing so is pointless given the plethora of GUI librar

Re: simple display (from: GUI library for D)

2011-04-09 Thread spir
On 04/09/2011 02:42 AM, Adam D. Ruppe wrote: OK. (But for this module I think usage simplicity is more > important than raw speed. The struct is at least equal in simplicity: image[x, y] = Color(r, g, b); vs image[x, y] = tuple(r, g, b); Indeed; and then: image[x, y].g versus image

Re: Struct copy and destruction

2011-04-09 Thread spir
On 04/09/2011 10:00 AM, Morlan wrote: The following code: //*** import std.conv, std.stdio; struct Slice { int[] buff; this(size_t len) { buff = new int[len]; } this(this) { buff = bu

Re: simple display (from: GUI library for D)

2011-04-09 Thread spir
On 04/09/2011 03:30 AM, Adam D. Ruppe wrote: bearophile wrote: > With Color is becomes something like: > foreach (col; zip(reds, greens, blues)) > image[x, y] = Color(col.tupleof); That looks perfectly acceptable to me. I might add an overload so opIndex can take a tuple too though, so

Re: Is the world coming to an end?

2011-04-08 Thread spir
On 04/08/2011 10:01 PM, Nick Sabalausky wrote: "Michel Fortin" wrote in message news:inn4bp$57s$1...@digitalmars.com... On 2011-04-08 07:03:23 -0400, spir said: On 04/08/2011 07:25 AM, Nick Sabalausky wrote: I want base PI literals :) Yum. I want base 1 literals Denis

Re: string and char[]

2011-04-08 Thread spir
On 04/08/2011 09:20 PM, Steven Schveighoffer wrote: On Fri, 08 Apr 2011 14:57:52 -0400, spir wrote: On 04/08/2011 03:13 PM, Steven Schveighoffer wrote: On Fri, 08 Apr 2011 06:44:42 -0400, Simen kjaeraas wrote: On Fri, 08 Apr 2011 12:46:08 +0200, Morlan wrote: It is OK if I write int

Re: string and char[]

2011-04-08 Thread spir
On 04/08/2011 03:40 PM, Denis Koroskin wrote: What about storing objects as keys? There is nothing wrong to modify those objects as long as their order stays the same. I think if referenced objects are to be used as keys, they should be compared by pointer/identity (hash would return their add

Re: string and char[]

2011-04-08 Thread spir
On 04/08/2011 03:13 PM, Steven Schveighoffer wrote: On Fri, 08 Apr 2011 06:44:42 -0400, Simen kjaeraas wrote: On Fri, 08 Apr 2011 12:46:08 +0200, Morlan wrote: It is OK if I write int[char[]] asr; asr["hello"] = 10; but the following does not compile: char[] car = "hello"; What is the

Re: Is the world coming to an end?

2011-04-08 Thread spir
On 04/08/2011 03:55 PM, Michel Fortin wrote: On 2011-04-08 07:03:23 -0400, spir said: On 04/08/2011 07:25 AM, Nick Sabalausky wrote: I want base PI literals :) Yum. I want base 1 literals Denis Like this? assert(0i == 0) assert(0i0 == 1) assert(0i00 == 2) assert(0i000 == 3) assert

Re: Is the world coming to an end?

2011-04-08 Thread spir
On 04/08/2011 07:25 AM, Nick Sabalausky wrote: I want base PI literals :) Yum. I want base 1 literals Denis -- _ vita es estrany spir.wikidot.com

Re: GSoC and licenses

2011-04-07 Thread spir
On 04/07/2011 09:32 PM, Fawzi Mohamed wrote: During a google summer of code project you are supposed to produce your own code. I also wasn't sure about the exact licensing needs, but as this is relevant for a project I tried to clarify the situation. As far as I understood if your code has to

Re: new dr. dobbs article by Walter

2011-04-07 Thread spir
On 04/07/2011 06:10 PM, Jason E. Aten wrote: Dr. Dobb's Journal just published a blog entry by Walter that discusses some of the motivation and design for the std/conv.d library. As a relative newcomer to D, I found it quite an interesting read. User Defined Literals in the D Programming Languag

  1   2   3   4   5   6   7   8   9   10   >