Re: Windows API Translation
Matthias Pleh wrote: Am 08.02.2011 22:37, schrieb Stewart Gordon: On 08/02/2011 12:25, Trass3r wrote: I wonder if these bindings would be suitable for inclusion in the core.sys.windows package? They definitely need to be merged. Merged? The whole point of the bindings project is that it will one day be complete. As such, it needs to _replace_ the current std.c.windows.* and core.sys.windows.*. Stewart. VisualD has some code for automated winapi-conversion: quoteto build the necessary D translations from the Windows and Visual Studio SDK/quote http://www.dsource.org/projects/visuald/wiki/Build_from_source Yes, building Visual D uses a tool that machine translates about 40 header and idl files from the Windows SDK (I tweaked it for versions 6.0A and 7.1A) and the full Visual Studio SDK. It filters out unused branches (mostly 64-bit), but tries to keep the rest similar to the original headers including comments. Preprocessor macros with arguments are translated to template functions. It uses const for most declaration including GUIDs, so you need to build a library and cannot simply import them in your project. Updating the import libraries needs coffimplib, implib32 does not work well enough. How well does SWIG handle the Windows API headers? Don wrote: Andrej Mitrovic wrote: Btw, how up-to-date are the import libs in windows/lib that ships with DMD2? Can they be used with e.g. Win7? They are horribly outdated. But I have a vague recollection that Walter has explicit permission from Microsoft to redistribute updated versions. If Walter not only has permission to distribute import libraries, but also the API header files, I could tweak it to support more of the 1200 header files (it often needs one or two special cases per file because of some preprocessor magic), so it could go into the dmd distribution. It is probably not perfectly compatible with core.sys.windows, though. Assuming redistribution is a problem, I was planning to add some conversion wizard to Visual D to let the user create the files from the C headers and libraries. Rainer
Re: Windows API Translation
Rainer Schuetze wrote: Matthias Pleh wrote: Am 08.02.2011 22:37, schrieb Stewart Gordon: On 08/02/2011 12:25, Trass3r wrote: I wonder if these bindings would be suitable for inclusion in the core.sys.windows package? They definitely need to be merged. Merged? The whole point of the bindings project is that it will one day be complete. As such, it needs to _replace_ the current std.c.windows.* and core.sys.windows.*. Stewart. VisualD has some code for automated winapi-conversion: quoteto build the necessary D translations from the Windows and Visual Studio SDK/quote http://www.dsource.org/projects/visuald/wiki/Build_from_source Yes, building Visual D uses a tool that machine translates about 40 header and idl files from the Windows SDK (I tweaked it for versions 6.0A and 7.1A) and the full Visual Studio SDK. It filters out unused branches (mostly 64-bit), but tries to keep the rest similar to the original headers including comments. Preprocessor macros with arguments are translated to template functions. It uses const for most declaration including GUIDs, so you need to build a library and cannot simply import them in your project. Updating the import libraries needs coffimplib, implib32 does not work well enough. How well does SWIG handle the Windows API headers? Don wrote: Andrej Mitrovic wrote: Btw, how up-to-date are the import libs in windows/lib that ships with DMD2? Can they be used with e.g. Win7? They are horribly outdated. But I have a vague recollection that Walter has explicit permission from Microsoft to redistribute updated versions. If Walter not only has permission to distribute import libraries, but also the API header files, I believe he does. But it was a newsgroup post many years ago, I don't trust my memory on that. I could tweak it to support more of the 1200 header files (it often needs one or two special cases per file because of some preprocessor magic), so it could go into the dmd distribution. It is probably not perfectly compatible with core.sys.windows, though. Assuming redistribution is a problem, I was planning to add some conversion wizard to Visual D to let the user create the files from the C headers and libraries. Rainer
Re: Please reply to this to vote to collectExceptionMsg in std.unittests
Andrei Alexandrescu wrote: Reply here to vote ONLY for the function collectExceptionMsg in Jonathan M Davis's std.unittests. Vote closes on Tue Feb 15. Andrei ++vote. It's worth noting that the exception chaining (as implemented in the Windows version of the next DMD2) means that it is possible for an exception to have a chain of messages attached to it. I'm not sure if this makes any difference or not -- it *could* be that we also want assert(e.next is null); inside collectExceptionMsg(), to make sure that there were no collateral exceptions. Or maybe we don't care -- but it needs to be mentioned in the docs.
Re: Stupid little iota of an idea
Nick Sabalausky: AUIU, foreach has both of these forms: D is currently very not-orthogonal. I have added the enhancement request time ago: http://d.puremagic.com/issues/show_bug.cgi?id=5395 http://d.puremagic.com/issues/show_bug.cgi?id=4112 Bye, bearophile
Re: Stupid little iota of an idea
== Quote from bearophile (bearophileh...@lycos.com)'s article D is currently very not-orthogonal. I think you might the person to ask this: I've seen the concept of orthogonality pop up more and more and it was especially prominent in the awkward Go vs D reddit discussion, can you maybe explain what it exactly means? And, also how it relates to your enhancement? I have added the enhancement request time ago: http://d.puremagic.com/issues/show_bug.cgi?id=5395 http://d.puremagic.com/issues/show_bug.cgi?id=4112 Bye, bearophile
Re: Stupid little iota of an idea
%u: can you maybe explain what it exactly means? And, also how it relates to your enhancement? In programming languages it means features that have fully separated purposes, that can be combined together in clean and safe ways to create more complex functionalities. Combining in clean and safe ways means they don't have unwanted interactions, their lower level nature is sufficiently encapsulated and doesn't leak out too much, so their sub-systems are mostly sealed, if you want to see it with systems theory ideas. In the current discussion foreach(i;iota(5)) and foreach(i;0..5) are usable for the same purpose, so those two features don't have fully separated purposes. On the other hand you can't use 0..5 where you want a lazy range: auto r = 0 .. 5; You need to us iota: auto r = iota(0, 5); So the 0..5 can't be combined to many other language functionalities to produce something bigger. This is why several people have asked for a more orthogonal interval syntax in D. Bye, bearophile
Re: Stupid little iota of an idea
== Quote from bearophile (bearophileh...@lycos.com)'s article %u: can you maybe explain what it exactly means? And, also how it relates to your enhancement? In programming languages it means features that have fully separated purposes, that can be combined together in clean and safe ways to create more complex functionalities. Combining in clean and safe ways means they don't have unwanted interactions, their lower level nature is sufficiently encapsulated and doesn't leak out too much, so their sub-systems are mostly sealed, if you want to see it with systems theory ideas. In the current discussion foreach(i;iota(5)) and foreach(i;0..5) are usable for the same purpose, so those two features don't have fully separated purposes. On the other hand you can't use 0..5 where you want a lazy range: auto r = 0 .. 5; You need to us iota: auto r = iota(0, 5); So the 0..5 can't be combined to many other language functionalities to produce something bigger. This is why several people have asked for a more orthogonal interval syntax in D. Bye, bearophile Thanks!! int[3] arr = [0..5:2];
inlining or not inlining...
Hello, Walter states that inline annotations are useless, since programmers cannot generally know which function /should/ be inlined --depending on a variety of factors, inlining may in fact be counter-productive. I totally agree, even more after having (superficially) explored the topic (mainly in LLVM docs). This point of view addresses one face of the question: namely when a given piece of code will be factored out into a separate function in any case, and we just wish it could be inlined. What if instead we wish this piece code inline in any case, even at the price of code duplication when it's used by several functions. The point is then different: we want to know whether the compiler will inline it, else we do it ourselves. If the compiler does, we are free to write the source in the optimal form for clarity; else, we are left and doing our best to prevent code obfuscation. This issue often happens to me, maybe, because I have high expectations on clarity, so that I tend to make functions for anything conceptually representing a whole task, even if tiny, even if used only by a single client func. (Structured programming is before all, for me, a tool for clarity, not to avoid code dup.) Thus, at best, we would need to know a bit about criteria used by the compiler for deciding whether to inline or not; provided a doc explaining this is at all readable by people who do not have the compiler-writer gene. Aside that, let us imagine an inline annotation beeing, not a request for inlining, but a request for compiler warning emission when inlining would not be applied to a given annotated func. Then, programmers would at least know, beeing thus able to choose on an informed basis. Complement to that may be a little (and hopefully clear) how-to guide on best chances to get a func inlined. This howto would start by describing most common and/or most critical criteria for the compiler to /not/ inline a given func. Then, a short set of negative positive examples actually generating or not the fatal warning. As a nice side-effect, such a doc may help make clear some schemes of (in)efficiency, in general, even for an inlined piece of code. (*) Denis By the way, I would love a [rather big] tutorial on efficiency -- what do you think? -- _ vita es estrany spir.wikidot.com
Re: Smartphones and D
Daniel Gibson metalcae...@gmail.com wrote in message news:iipq7m$8c0$1...@digitalmars.com... Am 31.01.2011 12:57, schrieb Daniel Gibson: Am 31.01.2011 12:04, schrieb dennis luehring: While workstations for developers have bigger and completely different requirements, in general the most demanding applications for ordinary sixpack-joe are hd-video transcoding (which actually isn't memory intensive), image manipulation (this year's basic $100 models already sport a sensor of 14 megapixels = 45 MB per image layer), and surprisingly web browsing. The ARM equipment support this by providing powerful co-processors and having a tiny (Thumb) instruction set. It's really hard to see where they would need more than 4 GB of RAM.. even according to Moore's law it will take at least 6 years for the top of the line products to use this much memory. but they work on 64bit: http://www.computerworld.com/s/article/9197298/Arm_readies_processing_cores_for_64_bit_computing Hmm I didn't know about that. I thought I read some months ago that porting ARM to 64bit is almost impossible. As a side note, a comment on the article: However, it's easy to imagine a service such as Amazon's EC2 offering virtualized Linux instances without the user being aware that it's an ARM setup, and these could be cheaper than equivalent x86 instances (perhaps even making for a budget EC2 service). This is BS, because the user is *directly* using EC2 VMs (can use his own binaries etc), so he *will* care if it runs x86 or ARM. And I don't think anyone would want to emulate x86 on ARM... Cheers, - Daniel http://www.thinq.co.uk/2011/2/7/arms-east-denies-64-bit-chip-plans/ OTOH, you can never trust anything a corporation says. Hell, Nintendo once famously stated flat out that they had no plans for a new DS model...and then announced the DS Lite the following day. Whether because of deliberate lie or just one hand not having the slightest clue what the other is doing, the word of a corporation can always be considered worthless.
Re: Filtering even numbers in various languages
On 02/09/2011 07:02 AM, Christopher Nicholson-Sauls wrote: On 02/08/11 19:02, Andrei Alexandrescu wrote: https://gist.github.com/817504 I added a D version. Andrei I would argue that (a 1 == 0) is a cheaper simple test for evenness... /gratuitous-nitpick Good show. Not really sure what the point of the list was... but sometimes these things are just (for) fun. -- Chris N-S Isn't this, precisely, a typical case of expected compiler rewrite? while n%2 far better expresses the concept in source (in absence of to-be-inlined isEven() or general isMultipleOf(), indeed). Denis -- _ vita es estrany spir.wikidot.com
Re: inlining or not inlining...
spir denis.s...@gmail.com wrote in message news:mailman.1420.1297253687.4748.digitalmar...@puremagic.com... By the way, I would love a [rather big] tutorial on efficiency -- what do you think? That would be great. Funny timing on your mentioning that, though: I just noticed today that one of my D programs appears to run half as fast when compiled with -release -O as it does with -debug. And no, that's not a typo or a juxtaposition. Haven't really dug into the matter, though.
Re: Stupid little iota of an idea
On 02/09/2011 04:08 AM, Nick Sabalausky wrote: AUIU, foreach has both of these forms: foreach(x; 0..5) foreach(x; someRange) Also, we have: auto someRange = iota(0, 5); Little idea: How about this genralized lowering? 0..5 // iota says Gimme some sugar, baby. // and thus it is lowered to - iota(0, 5) Of course, if that hinders optimization for foreach(x; 0..5), then the compiler could just optimize that particular case by not bothering with the lowering and doing as it currently does. But the benefit is things like this: // Stealing Andrei's filter even example: filter!`a % 2 == 0`(iota(1, 5)) // Give iota some sugar, baby: filter!`a % 2 == 0`(1..5) I suppose the obnoxious float-literal definition could get in the way, but when is it ever legal syntax in D to have two numeric literals next to each other? (And foreach seems ok with it anyway) Pardon if this has already been suggested. I like this. Maybe a slightly different approach would be for both 1..5 and iota(1,5) to be expressions for a simple and range-semantic-compatible struct-like thingy. Then, actually, iota would be superfluous, but some may still like it syntactically or semantically (because Iota is explicitely defined as a range type). Side-question: what is actually 1..5 as of now for a thing? Or is it conceptually unconstructed by rewriting to (probably) an ordinary for loop? Anyway, the point above applies to language-side semantics, whatever optimisation may happen. Denis -- _ vita es estrany spir.wikidot.com
Re: Stupid little iota of an idea
On 02/09/2011 04:08 AM, Nick Sabalausky wrote: AUIU, foreach has both of these forms: foreach(x; 0..5) foreach(x; someRange) Also, we have: auto someRange = iota(0, 5); Little idea: How about this genralized lowering? 0..5 // iota says Gimme some sugar, baby. // and thus it is lowered to - iota(0, 5) Of course, if that hinders optimization for foreach(x; 0..5), then the compiler could just optimize that particular case by not bothering with the lowering and doing as it currently does. But the benefit is things like this: // Stealing Andrei's filter even example: filter!`a % 2 == 0`(iota(1, 5)) // Give iota some sugar, baby: filter!`a % 2 == 0`(1..5) I suppose the obnoxious float-literal definition could get in the way, but when is it ever legal syntax in D to have two numeric literals next to each other? (And foreach seems ok with it anyway) Pardon if this has already been suggested. PS: your proposal would also logically allow, I guess, expressions like (n in min..max). Would love it. Denis -- _ vita es estrany spir.wikidot.com
Re: Stupid little iota of an idea
spir denis.s...@gmail.com wrote in message news:mailman.1422.1297254724.4748.digitalmar...@puremagic.com... Side-question: what is actually 1..5 as of now for a thing? Or is it conceptually unconstructed by rewriting to (probably) an ordinary for loop? Anyway, the point above applies to language-side semantics, whatever optimisation may happen. AIUI: Syntactically, it doesn't exist at all, at least not by itself. It's just part of one of the foreach syntaxes: 'foreach' '(' {declaration list} ';' {expression} '..' {expression} ')' and also part of one of the slice syntaxes: (from the docs:) PostfixExpression [ AssignExpression .. AssignExpression ] Although it's possible I've understood it wrong. Don't have a clue how it's handled beyond that though.
Re: Filtering even numbers in various languages
On 02/09/2011 03:02 AM, Andrei Alexandrescu wrote: https://gist.github.com/817504 I added a D version. Andrei I am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority.
Re: Stupid little iota of an idea
spir denis.s...@gmail.com wrote in message news:mailman.1423.1297254917.4748.digitalmar...@puremagic.com... PS: your proposal would also logically allow, I guess, expressions like (n in min..max). Would love it. Unfortunately, not unless in was changed to allow {expr} in {range}. And from prior discussions of in, I seem to remember Walter and Andrei are strongly against allowing in to be used to check for element values rather than just AA keys. But Andrei did recently propose an any, IIRC, that would allow something like what you're suggesting.
Re: D vs Go on reddit
Walter Bright newshou...@digitalmars.com wrote in message news:iicfaa$23j7$1...@digitalmars.com... http://www.reddit.com/r/programming/comments/fdqdn/google_go_just_got_major_win32_treats_now/c1f62a0 You'd think that things like JS, Haskell, LISP and Java circa v1.2 would have taught people that extreme simplicity/orthogonality is a stupid way to design a language that's intended to be used in the real world. But people keep flocking to that silver bullet anyway.
Re: High performance XML parser
On Tue, 08 Feb 2011 19:16:37 -0500, Tomek Sowiński j...@ask.me wrote: Steven Schveighoffer napisał: The design I'm thinking is that the node iterator will own a buffer. One consequence is that the fields of the current node will point to the buffer akin to foreach(line; File.byLine), so in order to lift the input the user will have to dup (or process the node in-place). As new nodes will be overwritten on the same piece of memory, an important trait of the design emerges: cache intensity. Because of XML namespaces I think it is necessary for the buffer to contain the current node plus all its parents. That might not scale well. For instance, if you are accessing the 1500th child element of a parent, doesn't that mean that the buffer must contain the full text for the previous 1499 elements in order to also contain the parent? Maybe I'm misunderstanding what you mean. Let's talk on an example: a name=value b Some Text 1 c2 !-- HERE -- Some text 2 /c2 Some Text 3 /b /a The buffer of the iterator positioned HERE would be: [Node a | Node b | Node c2] OK, so you mean a buffer other than the I/O buffer. This means double buffering data. I was thinking of a solution that allows simply using the I/O buffer for parsing. I think this is one of the keys to Tango's xml performance. -Steve
Re: DVCS vs. Subversion brittleness (was Re: Moving to D)
On 06/02/2011 14:17, Ulrik Mikaelsson wrote: 2011/2/4 Bruno Medeirosbrunodomedeiros+spam@com.gmail: Well, like I said, my concern about size is not so much disk space, but the time to make local copies of the repository, or cloning it from the internet (and the associated transfer times), both of which are not neglectable yet. My project at work could easily have gone to 1Gb of repo size if in the last year or so it has been stored on a DVCS! :S I hope this gets addressed at some point. But I fear that the main developers of both Git and Mercurial may be too biased to experience projects which are typically somewhat small in size, in terms of bytes (projects that consist almost entirely of source code). For example, in UI applications it would be common to store binary data (images, sounds, etc.) in the source control. The other case is what I mentioned before, wanting to store dependencies together with the project (in my case including the javadoc and source code of the dependencies - and there's very good reasons to want to do that). I think the storage/bandwidth requirements of DVCS:s are very often exagerated, especially for text, but also somewhat for blobs. * For text-content, the compression of archives reduces them to, perhaps, 1/5 of their original size? - That means, that unless you completely rewrite a file 5 times during the course of a project, simple per-revision-compression of the file will turn out smaller, than the single uncompressed base-file that subversion transfers and stores. - The delta-compression applied ensures small changes does not count as a rewrite. * For blobs, the archive-compression may not do as much, and they certainly pose a larger challenge for storing history, but: - AFAIU, at least git delta-compresses even binaries so even changes in them might be slightly reduced (dunno about the others) - I think more and more graphics are today are written in SVG? - I believe, for most projects, audio-files are usually not changed very often, once entered a project? Usually existing samples are simply copied in? * For both binaries and text, and for most projects, the latest revision is usually the largest. (Projects usually grow over time, they don't consistently shrink) I.E. older revisions are, compared to current, much much smaller, making the size of old history smaller compared to the size of current history. Finally, as a test, I tried checking out the last version of druntime from SVN and compare it to git (AFICT, history were preserved in the git-migration), the results were about what I expected. Checking out trunk from SVN, and the whole history from git: SVN: 7.06 seconds, 5,3 MB on disk Git: 2.88 seconds, 3.5 MB on disk Improvement Git/SVN: time reduced by 59%, space reduced by 34%. I did not measure bandwidth, but my guess is it is somewhere between the disk- and time- reductions. Also, if someone has an example of a recently converted repository including some blobs it would make an interesting experiment to repeat. Regards / Ulrik - ulrik@ulrik ~/p/test time svn co http://svn.dsource.org/projects/druntime/trunk druntime_svn ... 0.26user 0.21system 0:07.06elapsed 6%CPU (0avgtext+0avgdata 47808maxresident)k 544inputs+11736outputs (3major+3275minor)pagefaults 0swaps ulrik@ulrik ~/p/test du -sh druntime_svn 5,3Mdruntime_svn ulrik@ulrik ~/p/test time git clone git://github.com/D-Programming-Language/druntime.git druntime_git ... 0.26user 0.06system 0:02.88elapsed 11%CPU (0avgtext+0avgdata 14320maxresident)k 3704inputs+7168outputs (18major+1822minor)pagefaults 0swaps ulrik@ulrik ~/p/test du -sh druntime_git/ 3,5Mdruntime_git/ Yes, Brad had posted some statistics of the size of the Git repositories for dmd, druntime, and phobos, and yes, they are pretty small. Projects which contains practically only source code, and little to no binary data are unlikely to grow much and repo size ever be a problem. But it might not be the case for other projects (also considering that binary data is usually already well compressed, like .zip, .jpg, .mp3, .ogg, etc., so VCS compression won't help much). It's unlikely you will see converted repositories with a lot of changing blob data. DVCS, at the least in the way they work currently, simply kill this workflow/organization-pattern. I very much suspect this issue will become more important as time goes on - a lot of people are still new to DVCS and they still don't realize the full implications of that architecture with regards to repo size. Any file you commit will add to the repository size *FOREVER*. I'm pretty sure we haven't heard the last word on the VCS battle, in that in a few years time people are *again* talking about and switching to another VCS :( . Mark these words. (The only way this is not going to happen is if Git or Mercurial are able to address this issue in a satisfactory way, which I'm not sure is possible or easy) -- Bruno
Re: DVCS vs. Subversion brittleness (was Re: Moving to D)
On 04/02/2011 20:11, Michel Fortin wrote: On 2011-02-04 11:12:12 -0500, Bruno Medeiros brunodomedeiros+spam@com.gmail said: Can Git really have an usable but incomplete local clone? Yes, it's called a shallow clone. See the --depth switch of git clone: http://www.kernel.org/pub/software/scm/git/docs/git-clone.html I was about to say Cool!, but then I checked the doc on that link and it says: A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. So it's actually not good for what I meant, since it is barely usable (you cannot push from it). :( -- Bruno Medeiros - Software Engineer
Re: Stupid little iota of an idea
On 2/9/11 7:54 AM, Nick Sabalausky wrote: spirdenis.s...@gmail.com wrote in message news:mailman.1423.1297254917.4748.digitalmar...@puremagic.com... PS: your proposal would also logically allow, I guess, expressions like (n in min..max). Would love it. Unfortunately, not unless in was changed to allow {expr} in {range}. And from prior discussions of in, I seem to remember Walter and Andrei are strongly against allowing in to be used to check for element values rather than just AA keys. But Andrei did recently propose an any, IIRC, that would allow something like what you're suggesting. a in iota(min, max) is a O(1) operation so it could be allowed. Andrei
Re: Stupid little iota of an idea
On 2/9/11 7:46 AM, Nick Sabalausky wrote: spirdenis.s...@gmail.com wrote in message news:mailman.1422.1297254724.4748.digitalmar...@puremagic.com... Side-question: what is actually 1..5 as of now for a thing? Or is it conceptually unconstructed by rewriting to (probably) an ordinary for loop? Anyway, the point above applies to language-side semantics, whatever optimisation may happen. AIUI: Syntactically, it doesn't exist at all, at least not by itself. It's just part of one of the foreach syntaxes: 'foreach' '(' {declaration list} ';' {expression} '..' {expression} ')' and also part of one of the slice syntaxes: (from the docs:) PostfixExpression [ AssignExpression .. AssignExpression ] Although it's possible I've understood it wrong. Don't have a clue how it's handled beyond that though. Indeed, a..b is just punctuation in the two grammatical constructs you mentioned. Your proposal has indeed been made a couple of times, first probably by bearophile - but then what did bearophile /not/ propose? (Meaning this in good fun.) I think it would be okay to move iota into druntime and enact the rewrite. But this would improve the language by such a small iota... I buy the orthogonality argument as much as you do. foreach is not orthogonal because it is a short form of for, which is not orthogonal because it is a short form of while, which is not orthogonal because it is a short form of a scope with if/goto at the top. If a..b would be rewritten into iota(a, b) that would still be non-orthogonal because one could express one thing in two ways. Ironically, it's more orthogonal to leave things as they are: you have iota(a, b) as the general concept and you have a..b as punctuation in two grammatical constructs. But the most important question is: if the rewrite were done, to what extent would that improve your use of the language? Integral intervals do occur outside foreach and slices, but quite infrequently. In those cases you'd gain by replacing iota(a, b) with a..b. Is this significant? Andrei
Re: D vs Go on reddit
On 02/09/2011 02:01 PM, Nick Sabalausky wrote: Walter Brightnewshou...@digitalmars.com wrote in message news:iicfaa$23j7$1...@digitalmars.com... http://www.reddit.com/r/programming/comments/fdqdn/google_go_just_got_major_win32_treats_now/c1f62a0 You'd think that things like JS, Haskell, LISP and Java circa v1.2 would have taught people that extreme simplicity/orthogonality is a stupid way to design a language that's intended to be used in the real world. But people keep flocking to that silver bullet anyway. Yop! this said, I recently read (no pointer, sorry) about a possibly interesting third way: making the core language as close to orthogonal as possible w/o making the rest difficult, then build compromises as sugar layers around (syntactic semantic). This may be, actually, more or less close to how some actual languages are actually constructed; but I find that making this principle intentonal and intentional totally changes the whole approach. Also think this well fits the design of PL with a main/core paradigm/style (not so for D, probably). Denis -- _ vita es estrany spir.wikidot.com
Re: Stupid little iota of an idea
On 02/09/2011 01:54 PM, Nick Sabalausky wrote: spirdenis.s...@gmail.com wrote in message news:mailman.1423.1297254917.4748.digitalmar...@puremagic.com... PS: your proposal would also logically allow, I guess, expressions like (n in min..max). Would love it. Unfortunately, not unless in was changed to allow {expr} in {range}. And from prior discussions of in, I seem to remember Walter and Andrei are strongly against allowing in to be used to check for element values rather than just AA keys. But Andrei did recently propose an any, IIRC, that would allow something like what you're suggesting. IIRC, they did not argue against it for ranges specifically, but for it beeing O(n) for conceptually sequential collections like plain arrays, unlike for AAs, thus misleading in terms of efficiency. But 'in' is O(1) for an interval ;-) So, there is no reason to disallow it, instead such a feature would be both obvious useful. Denis -- _ vita es estrany spir.wikidot.com
Re: DVCS vs. Subversion brittleness (was Re: Moving to D)
On 2011-02-09 07:49:31 -0500, Bruno Medeiros brunodomedeiros+spam@com.gmail said: On 04/02/2011 20:11, Michel Fortin wrote: On 2011-02-04 11:12:12 -0500, Bruno Medeiros brunodomedeiros+spam@com.gmail said: Can Git really have an usable but incomplete local clone? Yes, it's called a shallow clone. See the --depth switch of git clone: http://www.kernel.org/pub/software/scm/git/docs/git-clone.html I was about to say Cool!, but then I checked the doc on that link and it says: A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. So it's actually not good for what I meant, since it is barely usable (you cannot push from it). :( Actually, pushing from a shallow repository can work, but if your history is not deep enough it will be a problem when git tries determine the common ancestor. Be sure to have enough depth so that your history contains the common ancestor of all the branches you might want to merge, and also make sure the remote repository won't rewrite history beyond that point and you should be safe. At least, that's what I understand from: http://git.661346.n2.nabble.com/pushing-from-a-shallow-repo-allowed-td2332252.html -- Michel Fortin michel.for...@michelf.com http://michelf.com/
Re: inlining or not inlining...
This howto would start by describing most common and/or most critical criteria for the compiler to /not/ inline a given func. Well if I read the code correctly: - inline assembler - variadic functions (string s, ...) - synchronized - imported functions - functions with closure vars - virtual functions that aren't final - functions with out, ref or static array parameters - functions with more than 250 elementary expressions
Re: inlining or not inlining...
At least back in 2010: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Is_there_a_way_to_get_a_list_of_functions_that_get_inlined_by_dmd_18798.html#N18810
Re: inlining or not inlining...
On 02/09/2011 03:53 PM, Trass3r wrote: This howto would start by describing most common and/or most critical criteria for the compiler to /not/ inline a given func. Well if I read the code correctly: - inline assembler - variadic functions (string s, ...) - synchronized - imported functions - functions with closure vars - virtual functions that aren't final - functions with out, ref or static array parameters - functions with more than 250 elementary expressions Very interesting. What do you think about the compiler telling Function f in module m not inlined? Guess it would (just) need a flag 'inliningRequested' set by the parser in whatever structure represents a func. Denis -- _ vita es estrany spir.wikidot.com
Re: Filtering even numbers in various languages
Max Samukha: I am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority. Well, compared to C++, a Java programmer needs to keep in mind far less arbitrary details, that if forgotten cause many bugs in C++ programs. Java compiler is strict and catches many bugs, it works well enough, and you just need small jars to distribute the compilation result. Today Java works on many machines, on 32 and 64 bit well enough, there are tons of libraries, Java programmers that you are able to hire, tons of tools to edit/debug/improve Java code, Java is today pretty fast and its GC is first world class. There are even other languages like Scala and Jthon that run on the JVM and interoperate with it and its libs. Given all that, the verbose syntax of Java becomes a minor thing. Java is full of faults and downsides, but most other languages/language ecosystems are worse. Bye, bearophile
Re: Stupid little iota of an idea
Andrei: But the most important question is: if the rewrite were done, to what extent would that improve your use of the language? Integral intervals do occur outside foreach and slices, but quite infrequently. In those cases you'd gain by replacing iota(a, b) with a..b. Is this significant? I can list you why I think an interval syntax is better, but at the end you need to judge values: - The basic range syntax is already present in two different situations in the language, for slices and foreach (switch-case statement use the dot-dot syntax for a related but different purpose). So D programmers don't need to learn a new syntax, the cognitive cost is probably negative. - The 1 .. 5 syntax is present in math too (even if it often means a set closed on the right too). - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. - Both 1..5 and iota(1,5) are able to support the in operator. This is good because D doesn't support the aXb Python syntax. X in a..b will mean a=Xb. - If the compiler front-end becomes aware of the interval syntax, it is able to perform 3 in 1..10 at compile-time too, simplifying sub-expressions even when they are inside other run-time expressions. - With the interval syntax there is no need to import std.range, that's necessary for iota(). - the a..b syntax is shorter and a bit less noisy: array(1..5) compared to array(iota(1,5)). - The a..b syntax is extendible to cover the third stride argument of iota(). I suggest a..b:c (The stride syntax is later usable for arrays too if the stride is a compile-time constant). Python shows several nice usages of the stride argument. - Currently foreach(i; retro(iota(...))) or even foreach(i; iota(...)) are not as fast as foreach(i; ...). I hope this interval syntax will help DMD digest a lazy interval more efficiently. - Interesting point, to translate this to interval syntax: iota(1.,-5.) it becomes 1...5. that's a mess. You need zeros: 1.0 .. 5.0 - Another interesting point, currently the semantics of iota() and the interval in foreach are not the same, only the second loop here raises an exception: import std.stdio, std.range; void main() { foreach (x; 1 .. -5) writeln(x); foreach (x; iota(1, -5)) writeln(x); } In my opinion iota() semantics here must be the same as the foreach interval, and yield an empty iterable with no errors: http://d.puremagic.com/issues/show_bug.cgi?id=4603 I like the interval literal syntax for static things too, example: http://d.puremagic.com/issues/show_bug.cgi?id=4085 static foreach (x; 1 .. -5) A first class literal syntax in D (typeid(typeof(1..5)) gives a new type) may become useful for slices too in objects/structs, this is Python 2.6 code: class Foo(object): def __getitem__(self, key): print key f = Foo() f[1:2] Output: slice(1, 2, None) Bye, bearophile
Re: High performance XML parser
Steven Schveighoffer napisał: OK, so you mean a buffer other than the I/O buffer. This means double buffering data. I was thinking of a solution that allows simply using the I/O buffer for parsing. I think this is one of the keys to Tango's xml performance. I'd be glad to hear what's your idea. I think they are convergent. In mine, the I/O could be asked to dump data to the iterator's buffer at a given position (right to previous nodes), then the iterator forms a node out of raw data. Some moving would be done but all within the cached buffer so should be quick. I guess it's as far as I can predict performance in a newsgroup post. ;-) Gotta write some code and whip out the stopwatch, then we'll see. -- Tomek
Re: Stupid little iota of an idea
Am 09.02.2011 19:54, schrieb bearophile: - Both 1..5 and iota(1,5) are able to support the in operator. This is good because D doesn't support the aXb Python syntax. X in a..b will mean a=Xb. Don't know about Python, but in D this will only be true if X is an integer. I guess 1X4 is true for X=1.5 in Python.. it would certainly not be true for X in 1..4 in D. Also using X in 1..4 is in D is pretty bad if you just want to check if 1X4 (or even more when checking 1X100) because it has a much higher overhead - even though it may be technically O(1) because 4 or 100 is a constant) than just doing two comparisons. So IMHO using X in 1..4 or x in iota(1,4) should not be encouraged. (X in [1,3,4,8] is different.) Of course the compiler could transform X in 1..4 to X1 X4, but... I don't think it's a good idea. If this syntax is accepted, 1..4 should create a range/array containing [1,2,3] - without addidional voodoo. - If the compiler front-end becomes aware of the interval syntax, it is able to perform 3 in 1..10 at compile-time too, simplifying sub-expressions even when they are inside other run-time expressions. Cheers, - Daniel
Re: Stupid little iota of an idea
%u Wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article D is currently very not-orthogonal. I think you might the person to ask this: I've seen the concept of orthogonality pop up more and more and it was especially prominent in the awkward Go vs D reddit discussion, can you maybe explain what it exactly means? And, also how it relates to your enhancement? Orthogonal is one of those terms people like to use because it makes them sound smart. Bearophile has provided a good explanation of how it relates to programming languages, and hasn't been abusing the term. The discussion on Reddit was awkward because there where a few that couldn't consistently use 'orthogonal.' For example I got one person to say that for him orthogonality is when there are no exceptions to a rule/feature, yet somehow nested functions where not orthogonal. Then even once everyone agrees on what the term means, there are good arguments as to why you wouldn't want to be completely orthogonal. And at this point many will just assert not being orthogonal is always bad, with the universal reason being It is something more you have to remember. Which is not the purpose of orthogonality at all, and being orthogonal doesn't even mean you'll have less to remember. So my opinion is to just make a statement of what is wrong and leave whether it is related to orthogonality out of it. And even if it is labeled correctly it best to be specific anyway so people aren't left guessing as to why.
Re: D vs Go on reddit
Nick Sabalausky wrote: Walter Bright newshou...@digitalmars.com wrote in message news:iicfaa$23j7$1...@digitalmars.com... http://www.reddit.com/r/programming/comments/fdqdn/google_go_just_got_major_win32_treats_now/c1f62a0 You'd think that things like JS, Haskell, LISP and Java circa v1.2 would have taught people that extreme simplicity/orthogonality is a stupid way to design a language that's intended to be used in the real world. But people keep flocking to that silver bullet anyway. Yeah, I've been thinking of doing my next presentation on the topic of false simplicity.
Re: DVCS vs. Subversion brittleness (was Re: Moving to D)
Bruno Medeiros wrote: Yes, Brad had posted some statistics of the size of the Git repositories for dmd, druntime, and phobos, and yes, they are pretty small. Projects which contains practically only source code, and little to no binary data are unlikely to grow much and repo size ever be a problem. But it might not be the case for other projects (also considering that binary data is usually already well compressed, like .zip, .jpg, .mp3, .ogg, etc., so VCS compression won't help much). It's unlikely you will see converted repositories with a lot of changing blob data. DVCS, at the least in the way they work currently, simply kill this workflow/organization-pattern. I very much suspect this issue will become more important as time goes on - a lot of people are still new to DVCS and they still don't realize the full implications of that architecture with regards to repo size. Any file you commit will add to the repository size *FOREVER*. I'm pretty sure we haven't heard the last word on the VCS battle, in that in a few years time people are *again* talking about and switching to another VCS :( . Mark these words. (The only way this is not going to happen is if Git or Mercurial are able to address this issue in a satisfactory way, which I'm not sure is possible or easy) There are several Mercurial extensions that attempt to address this issue. See for example: http://wiki.netbeans.org/HgExternalBinaries or http://mercurial.selenic.com/wiki/BigfilesExtension I do not know how well they perform in practice. Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr signature.asc Description: OpenPGP digital signature
Re: Stupid little iota of an idea
Daniel Gibson: Don't know about Python, but in D this will only be true if X is an integer. I guess 1X4 is true for X=1.5 in Python.. it would certainly not be true for X in 1..4 in D. You are right, the semantics is different, my silly mistake. Thank you. Also using X in 1..4 is in D is pretty bad if you just want to check if 1X4 (or even more when checking 1X100) because it has a much higher overhead - even though it may be technically O(1) because 4 or 100 is a constant) Even if the bounds are not constants it's not hard to perform x in a..b in O(1). Bye, bearophile
Re: Stupid little iota of an idea
Am 09.02.2011 20:57, schrieb bearophile: Daniel Gibson: Don't know about Python, but in D this will only be true if X is an integer. I guess 1X4 is true for X=1.5 in Python.. it would certainly not be true for X in 1..4 in D. You are right, the semantics is different, my silly mistake. Thank you. Also using X in 1..4 is in D is pretty bad if you just want to check if 1X4 (or even more when checking 1X100) because it has a much higher overhead - even though it may be technically O(1) because 4 or 100 is a constant) Even if the bounds are not constants it's not hard to perform x in a..b in O(1). If the compiler does optimizations (= transforms it to if( a=x xb)), yes. If a..b are handled as a generic range (just like e.g. [1, 10, 4, 7, 3, 42]) I don't think it's as easy in constant time. Maybe when putting the range into a hash table.. but this also has some overhead. Bye, bearophile Cheers, - Daniel
Re: Stupid little iota of an idea
On 2/9/11 3:54 PM, bearophile wrote: - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. I would recommend stop using weird names for functions. Sorry if this sounds a little harsh but the only reason I see this function is called iota is to demonstrate knowledge (or to sound cool). But programmers using a language don't care about whether the other programmer demonstrates knowledge behind a function name, they just want to get things done, fast. I mean, if I want to create a range of numbers I would search range. iota will never, ever come to my mind. D has to be more open to public, not only to people who programmed in APL, Go or are mathematics freaks. Guess how a range is called in Ruby? That's right, Range. Another example: retro. The documentation says iterates a bidirectional name backwards. Hm, where does retro appear in that text? If I want to iterate it backwards, or to reverse the order, the first thing I would write is reverse(range) or backwards(range), retro would never come to my mind. (and no, replies like you can always alias xxx are not accepted :-P)
Re: Stupid little iota of an idea
Am 09.02.2011 21:08, schrieb Ary Manzana: On 2/9/11 3:54 PM, bearophile wrote: - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. I would recommend stop using weird names for functions. Sorry if this sounds a little harsh but the only reason I see this function is called iota is to demonstrate knowledge (or to sound cool). But programmers using a language don't care about whether the other programmer demonstrates knowledge behind a function name, they just want to get things done, fast. I mean, if I want to create a range of numbers I would search range. iota will never, ever come to my mind. D has to be more open to public, not only to people who programmed in APL, Go or are mathematics freaks. Guess how a range is called in Ruby? That's right, Range. Another example: retro. The documentation says iterates a bidirectional name backwards. Hm, where does retro appear in that text? If I want to iterate it backwards, or to reverse the order, the first thing I would write is reverse(range) or backwards(range), retro would never come to my mind. (and no, replies like you can always alias xxx are not accepted :-P) I agree that iota is a bad name, but Range is a bad name because it's already used in D. Cheers, - Daniel
Re: Stupid little iota of an idea
Ary Manzana wrote: On 2/9/11 3:54 PM, bearophile wrote: - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. I would recommend stop using weird names for functions. Sorry if this sounds a little harsh but the only reason I see this function is called iota is to demonstrate knowledge (or to sound cool). But programmers using a language don't care about whether the other programmer demonstrates knowledge behind a function name, they just want to get things done, fast. I mean, if I want to create a range of numbers I would search range. iota will never, ever come to my mind. D has to be more open to public, not only to people who programmed in APL, Go or are mathematics freaks. Guess how a range is called in Ruby? That's right, Range. Another example: retro. The documentation says iterates a bidirectional name backwards. Hm, where does retro appear in that text? If I want to iterate it backwards, or to reverse the order, the first thing I would write is reverse(range) or backwards(range), retro would never come to my mind. Well, at least “retro” is compatible with the dictionary signification of the word, so even though it is not the first word that would come to mind when searching how to reverse a list, it should be pretty self explanatory when reading existing code. OTOH, “iota” is not and could even be argued to be antonymous to the dictionary meaning, which makes it all that much more difficult to understand. Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr signature.asc Description: OpenPGP digital signature
LAPACK/BLAS/SciD Windows
Has anyone been able to get BLAS/LAPACK/SciD working on Windows? If so, how? The furthest I've gotten is building SciD, downloading BLAS and LAPACK prebuilt binaries from http://icl.cs.utk.edu/lapack-for-windows/, and using Agner Fog's objconv to convert them from COFF to OMF. Then, when I try to build a trivial test program, I get: Symbol Undefined _dgetri_ Symbol Undefined _dgetrf_ Grepping my lapack binaries indicates that getri and getrf are there, but _getri_ and _getrf_ are not. It's an underscore issue. Can anyone either: 1. Tell me how to fix this? 2. Tell me where to get BLAS and LAPACK in OMF format that will just work with DMD?
Re: std.unittests/exception Update and Vote
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vqm05qx8eav7ka@steve-laptop... *playing* in the snow is way different than *battling* the snow :) Not to me ;) (It's freeze your nuts off either way.)
Re: Filtering even numbers in various languages
On 02/09/2011 08:06 PM, bearophile wrote: Max Samukha: I am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority. Well, compared to C++, a Java programmer needs to keep in mind far less arbitrary details, that if forgotten cause many bugs in C++ programs. Java compiler is strict and catches many bugs, it works well enough, and you just need small jars to distribute the compilation result. Today Java works on many machines, on 32 and 64 bit well enough, there are tons of libraries, Java programmers that you are able to hire, tons of tools to edit/debug/improve Java code, Java is today pretty fast and its GC is first world class. There are even other languages like Scala and Jthon that run on the JVM and interoperate with it and its libs. Given all that, the verbose syntax of Java becomes a minor thing. Java is full of faults and downsides, but most other languages/language ecosystems are worse. Bye, bearophile I was referring to the particular posters who praised the Java solution, which is obviously inferior to nearly every 'filter' variant provided by other posters.
Re: LAPACK/BLAS/SciD Windows
AFAIK objconv has the +nu or a similar switch that adds underscores to symbol names. Hope that helps.
Re: LAPACK/BLAS/SciD Windows
That's -nu+ actually, or alternatively -au+ which just adds aliases to existing symbols. On 2/9/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: AFAIK objconv has the +nu or a similar switch that adds underscores to symbol names. Hope that helps.
Re: D vs Go on reddit
spir denis.s...@gmail.com wrote in message news:mailman.1424.1297260589.4748.digitalmar...@puremagic.com... On 02/09/2011 02:01 PM, Nick Sabalausky wrote: Walter Brightnewshou...@digitalmars.com wrote in message news:iicfaa$23j7$1...@digitalmars.com... http://www.reddit.com/r/programming/comments/fdqdn/google_go_just_got_major_win32_treats_now/c1f62a0 You'd think that things like JS, Haskell, LISP and Java circa v1.2 would have taught people that extreme simplicity/orthogonality is a stupid way to design a language that's intended to be used in the real world. But people keep flocking to that silver bullet anyway. Yop! this said, I recently read (no pointer, sorry) about a possibly interesting third way: making the core language as close to orthogonal as possible w/o making the rest difficult, then build compromises as sugar layers around (syntactic semantic). This may be, actually, more or less close to how some actual languages are actually constructed; but I find that making this principle intentonal and intentional totally changes the whole approach. Also think this well fits the design of PL with a main/core paradigm/style (not so for D, probably). Yea, that seems to be the direction that post-v1.2 Java ended up taking. Still too little, too late, IMO, at least in the case of Java, but it may not necessarily be a bad idea. Although I do like the inverse approach that D ended up taking: Don't bother with simplicity/orthogonality at first, just get important features in. *Then* refactor the internals to shuffle the complexity into the std lib and simplify the core language. (And, of course, use lowerings whenever appropriate.) Funny though, right after I posted You'd think that things like JS..., the obvious devil's-advocate counter-argument occurred to me: You'd think that things like C++ and Algol would have taught people that complex languages are a stupid way to go. Oh well.
Re: D vs Go on reddit
2011/2/9 spir denis.s...@gmail.com: Yop! this said, I recently read (no pointer, sorry) about a possibly interesting third way: making the core language as close to orthogonal as possible w/o making the rest difficult, then build compromises as sugar layers around (syntactic semantic). This may be, actually, more or less close to how some actual languages are actually constructed; but I find that making this principle intentonal and intentional totally changes the whole approach. Also think this well fits the design of PL with a main/core paradigm/style (not so for D, probably). Isn't this how much of JavaScript is ACTUALLY used nowadays? jQuery, YUI, PrototypeJS? Coding for limited embedded hardware, I'm personally hand-coding Javascript (without 3:d-party-libs) at work ATM, since I really need to know all effects (especially on the DOM) of everything I do. (Is something reading .offsetHeight? - i DEFINITELY need to know about it.) Outside the realm of embedded/limited hardware though, it seems few people are actually coding in pure JavaScript without convenience-libraries. Maybe it's the ASM of next decade.
Re: DVCS vs. Subversion brittleness (was Re: Moving to D)
2011/2/9 Bruno Medeiros brunodomedeiros+spam@com.gmail: It's unlikely you will see converted repositories with a lot of changing blob data. DVCS, at the least in the way they work currently, simply kill this workflow/organization-pattern. I very much suspect this issue will become more important as time goes on - a lot of people are still new to DVCS and they still don't realize the full implications of that architecture with regards to repo size. Any file you commit will add to the repository size *FOREVER*. I'm pretty sure we haven't heard the last word on the VCS battle, in that in a few years time people are *again* talking about and switching to another VCS :( . Mark these words. (The only way this is not going to happen is if Git or Mercurial are able to address this issue in a satisfactory way, which I'm not sure is possible or easy) You don't happen to know about any projects of this kind in any other VCS that can be practically tested, do you? Besides, AFAIU this discussion was originally regarding to the D language components, I.E. DMD, druntime and Phobos. Not a lot of binaries here.
More on Rust
The Development of the Rust language from Mozilla and Graydon Hoare is going on. It will probably become a quite interesting system language, quite more interesting than Go. One of the most interesting features of Rust will be its typestate. Rust has structural typing too, this is sometimes useful (but to use it well you need something like pattern matching used in functional languages like ML, that I don't know if is present in Rust). Graydon is following D idea of putting a basic unit testing feature in the language: https://mail.mozilla.org/pipermail/rust-dev/2010-December/000160.html https://mail.mozilla.org/pipermail/rust-dev/2010-December/000163.html https://mail.mozilla.org/pipermail/rust-dev/2010-December/000165.html Rust also puts basic logging as a built-in feature. This is a blog post about Rust type inference: http://pcwalton.blogspot.com/2010/10/rust-features-i-type-inference.html Rust doesn't have a whole program type inferencer (as ML), like a Hindley-Milner algorithm, to keep things simple and allow separate compilation (and probably to keep compilation times low, etc). So you have to give type to function arguments, and if you want you are free to use auto everywhere inside the function to infer types locally. I think this is good. So on this it's quite similar to D, but there are some differences. Rust allows to do this (log is a built-in logging feature, I don't know how they call the logarithm function): auto x; if (localtime().hours = 8) { x = awake! } else { x = asleep, go away. } log I'm + x; From the blog post: Rust features what I call feed-forward type inference, which is summed up by this rule: Variables have no type until they are assigned a value, at which point their type can't change. Here, we didn't initialize x in its declaration, but this code still compiles and runs properly. This is because Rust is able to wait until x is assigned to determine its type. Unlike, say, C# (and, of course, languages like ML in which variables must be assigned a value at declaration time), Rust doesn't require that auto declarations be initially assigned a value to determine a type for them. At the same time, unlike C, the compiler will emit an error if you ever forget to assign a value to the variable in any branch of your code. For instance, if you omit the else branch above, the code won't compile. Rust is statically typed, so this is an error, it's not possible (unless you use some kind of variant): log do you want to add strings or ints?; auto use_str = input.readline == strings; if (use_str) { a = hello ; b = world!; } else { a = 1; b = 1; } log a + b; Both branches of the if must assign the same types to a and b, like when in D you use an auto return type, and the D compiler makes sure all your return statements return exactly the same type. Variables have no type until they are assigned a value, at which point their type can't change. looks meaningless if you see types as timeless things, that are are always true and immutable for a variable. But in Rust there are typestates, so while a variable can't change type, its type sometimes changes state along the flow of the code, such state of the type may be different in different parts of the code. Bye, bearophile
Re: D vs Go on reddit
Nick Sabalausky wrote: Funny though, right after I posted You'd think that things like JS..., the obvious devil's-advocate counter-argument occurred to me: You'd think that things like C++ and Algol would have taught people that complex languages are a stupid way to go. Oh well. What matters is if I can express a program in a simple, straightforward manner. Not if the implementation language is simple or not. C++ fails at the former.
Re: More on Rust
Rust is statically typed, so this is an error, it's not possible (unless you use some kind of variant): Not quite clear in the example but just add an extra line after if block. log do you want to add strings or ints?; auto use_str = input.readline == strings; if (use_str) { a = hello ; b = world!; } else { a = 1; b = 1; } auto c = b - a; // wah? log a + b; ... Bye, bearophile Already love it, lowercase ftw! Although built-in logging is nice, both the name and the operator of logging are very bad choices. Especially for a standard library.
Re: basic incomplete NetBSD support
On 2/8/2011 6:37 AM, Thomas Klausner wrote: On Sun, Jan 30, 2011 at 09:23:50PM +0100, Thomas Klausner wrote: Since it looked like I would need D for a project, I started porting it to NetBSD. The project has been cancelled in the meantime, but I don't want my patches to be lost, so I offer them here for inclusion. Anyone interested? Thomas A newsgroup / mailing list post by definition will get lost. If you're interested in getting them folded in, a bugzilla entry with the patches will help, or even better a branch on github with the changes and a pull request. However, without a user base, it's almost certain that netbsd would bit rot. Later, Brad
Re: More on Rust
both the name and the operator of logging are very bad choices. Oh '+' is string concat in Rust, and log is not that bad either!
Re: basic incomplete NetBSD support
Brad Roberts wrote: On 2/8/2011 6:37 AM, Thomas Klausner wrote: On Sun, Jan 30, 2011 at 09:23:50PM +0100, Thomas Klausner wrote: Since it looked like I would need D for a project, I started porting it to NetBSD. The project has been cancelled in the meantime, but I don't want my patches to be lost, so I offer them here for inclusion. Anyone interested? Thomas A newsgroup / mailing list post by definition will get lost. If you're interested in getting them folded in, a bugzilla entry with the patches will help, or even better a branch on github with the changes and a pull request. I agree with Brad. However, without a user base, it's almost certain that netbsd would bit rot. We'd need to add a netbsd machine to the build/test farm!
Re: More on Rust
bearophile bearophileh...@lycos.com wrote in message news:iivb5n$na3$1...@digitalmars.com... auto x; if (localtime().hours = 8) { x = awake! } else { x = asleep, go away. } log I'm + x; That would be really nice to have in D. There's been many times I've needed to move a declaration up one scope from its initialization and was therefore forced to get rid of the auto. Not a major problem obviously, but that sure would be nice.
Re: D vs Go on reddit
Ulrik Mikaelsson ulrik.mikaels...@gmail.com wrote in message news:mailman.1430.1297292203.4748.digitalmar...@puremagic.com... Maybe [JS is] the ASM of next decade. There's been a lot of buzz about that. It's a thought I find horrifying. Hellraiser? Very cool. Child's Play? Downright *funny* at times. JS as the ASM of the future? Piss-my-pants, nightmares-all-month, frightening.
Re: Stupid little iota of an idea
Le 09/02/2011 21:08, Ary Manzana a écrit : On 2/9/11 3:54 PM, bearophile wrote: - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. I would recommend stop using weird names for functions. Sorry if this sounds a little harsh but the only reason I see this function is called iota is to demonstrate knowledge (or to sound cool). But programmers using a language don't care about whether the other programmer demonstrates knowledge behind a function name, they just want to get things done, fast. I mean, if I want to create a range of numbers I would search range. iota will never, ever come to my mind. D has to be more open to public, not only to people who programmed in APL, Go or are mathematics freaks. Guess how a range is called in Ruby? That's right, Range. Another example: retro. The documentation says iterates a bidirectional name backwards. Hm, where does retro appear in that text? If I want to iterate it backwards, or to reverse the order, the first thing I would write is reverse(range) or backwards(range), retro would never come to my mind. (and no, replies like you can always alias xxx are not accepted :-P) Hi, I agree iota is a bad name. FWIW, what comes to my mind when I read it is an idea of tininess, such as in the expression : It didn't change an iota. I certainly miss the mathematical reference. Retro is self explanatory when you read it, even if it is not the first to come to mind. Backwards may have been better. Reverse is already in std.algorithm and would have confused the user. Cheers, Olivier.
Re: Stupid little iota of an idea
On Wed, 09 Feb 2011 17:08:10 -0300, Ary Manzana wrote: On 2/9/11 3:54 PM, bearophile wrote: - There is no need to learn to use a function with a weird syntax like iota, coming from APL. This makes Phobos and learning D a bit simpler. I would recommend stop using weird names for functions. Sorry if this sounds a little harsh but the only reason I see this function is called iota is to demonstrate knowledge (or to sound cool). I believe 'iota' got its name from its sibling in C++'s STL: http://www.sgi.com/tech/stl/iota.html -Lars
allocating an array in an associative array
Hello, I want to allocate the int[] array for a particular key in int[][string] list; by doing list[key].length = list[key].length + 1; but it does not work. I get an array bounds error. I am using gdc 4.3.5. Any suggestions? Thank you, Dominic Jones
Re: allocating an array in an associative array
On Wed, 09 Feb 2011 07:58:12 -0500, Dominic Jones dominic.jo...@qmul.ac.uk wrote: Hello, I want to allocate the int[] array for a particular key in int[][string] list; by doing list[key].length = list[key].length + 1; but it does not work. I get an array bounds error. I am using gdc 4.3.5. Any suggestions? Try using the in operator: if(auto arr = key in list) // arr is now type int[]* { (*arr).length = (*arr).length + 1; } else list[key] = new int[1]; // or larger if desired It incurs a double lookup when the key doesn't exist yet, but I'm not sure you can do any better (unless you know ahead of time the key is not in the AA). The issue is you are looking up list[key] without it existing, that throws the array bounds. The in check in my code checks to see if it is present first before doing anything. If they key is present, then there's only a single lookup. -Steve
Template for function or delegate (nothing else)
Is it possible to create a template which only accepts functions or delegates like this example: class Example(T : void function()) { // or ..(T : void delegate()).. T callback; } Where T is a function or a delegate... Thanks for every suggestion!
Re: Template for function or delegate (nothing else)
On Wed, 09 Feb 2011 14:35:42 -0500, useo u...@start.bg wrote: Is it possible to create a template which only accepts functions or delegates like this example: class Example(T : void function()) { // or ..(T : void delegate()).. T callback; } Where T is a function or a delegate... Thanks for every suggestion! class Example(T) if (is(T == delegate) || is(T == function)) { T callback; } -Steve
Re: Template for function or delegate (nothing else)
== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 14:35:42 -0500, useo u...@start.bg wrote: Is it possible to create a template which only accepts functions or delegates like this example: class Example(T : void function()) { // or ..(T : void delegate ()).. T callback; } Where T is a function or a delegate... Thanks for every suggestion! class Example(T) if (is(T == delegate) || is(T == function)) { T callback; } -Steve Wow, works great - THANKS :)
Re: Template for function or delegate (nothing else)
useo: ... something like: void bindEvent(T)(if (is(T == delegate) || is(T == function)))()... void foo(T)(T x) if (is(T == delegate) || is(T == function)) { ... } Bye, bearophile
Re: Template for function or delegate (nothing else)
On Wed, 09 Feb 2011 14:59:33 -0500, useo u...@start.bg wrote: == Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 14:35:42 -0500, useo u...@start.bg wrote: Is it possible to create a template which only accepts functions or delegates like this example: class Example(T : void function()) { // or ..(T : void delegate ()).. T callback; } Where T is a function or a delegate... Thanks for every suggestion! class Example(T) if (is(T == delegate) || is(T == function)) { T callback; } -Steve Is there any chance to do the same for methods like: void example(T)() { } ... something like: void bindEvent(T)(if (is(T == delegate) || is(T == function)))()... Yes, but you have the order mixed up. void bindEvent(T)() if (is...) In general form, a template constraint goes after the declaration, but before the body of the template. -Steve
Re: Template for function or delegate (nothing else)
== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 14:59:33 -0500, useo u...@start.bg wrote: == Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 14:35:42 -0500, useo u...@start.bg wrote: Is it possible to create a template which only accepts functions or delegates like this example: class Example(T : void function()) { // or ..(T : void delegate ()).. T callback; } Where T is a function or a delegate... Thanks for every suggestion! class Example(T) if (is(T == delegate) || is(T == function)) { T callback; } -Steve Is there any chance to do the same for methods like: void example(T)() { } ... something like: void bindEvent(T)(if (is(T == delegate) || is(T == function))) ()... Yes, but you have the order mixed up. void bindEvent(T)() if (is...) In general form, a template constraint goes after the declaration, but before the body of the template. -Steve Ah, okay... I already tried the if-statement after the declaration but I always got an error like this: ... semicolon expected following function declaration I just removed ( and ) from the if-statement and it's working, thanks in again!
Invoke garbage collector?
I'm having an unfortunate DSFML issue, where failing to free objects like Images or Sprites causes exceptions to eventually be thrown. Calling the built-in member dispose() causes access violations, so I assume it's not for programmer use. However, I need the resources to be freed more quickly than the GC is apparently doing (I assume the Images and Sprites are eventually cleaned up), so is there a way to invoke a GC cleanup in some way?
Re: Invoke garbage collector?
Sean Eskapp: so is there a way to invoke a GC cleanup in some way? http://www.digitalmars.com/d/2.0/phobos/core_memory.html#minimize Bye, bearophile
Re: Template for function or delegate (nothing else)
I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function()) myVariable. But is there any possibility to use variables like Example myVariable? The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this.
Re: Invoke garbage collector?
On Wed, 09 Feb 2011 15:58:13 -0500, bearophile bearophileh...@lycos.com wrote: Sean Eskapp: so is there a way to invoke a GC cleanup in some way? http://www.digitalmars.com/d/2.0/phobos/core_memory.html#minimize This attempts to minimize memory, it does not run a collection cycle (I don't think anyways). To invoke the GC collector, use: http://www.digitalmars.com/d/2.0/phobos/core_memory.html#collect -Steve
Re: Template for function or delegate (nothing else)
On Wed, 09 Feb 2011 16:14:04 -0500, useo u...@start.bg wrote: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function()) myVariable. But is there any possibility to use variables like Example myVariable? The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. If I understand you correctly, you don't want to declare the type of T when instantiating the template? This is not possible, templates must have all parameters defined at instantiation time. If you just want a shorter thing to type for Example!(void function()), you can do: alias Example!(void function()) MyType; MyType myVariable; -Steve
Re: Template for function or delegate (nothing else)
useo: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function()) myVariable. But is there any possibility to use variables like Example myVariable? D is not the SML language, templates are just placeholders. If you don't instantiate a template, you have only a symbol. Example is only assignable to an alias (and in past, to a typedef): alias Example Foo; The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. I don't yet understand what you are trying to do. Other notes: - What if your T is a functor (a callable class/struct/union instance that defined opCall)? - sizeof of a function pointer is 1 CPU word, while a delegate is 2 CPU words (and a delegate clojure has stuff on the heap too, sometimes). Bye, bearophile
Re: Template for function or delegate (nothing else)
== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 16:14:04 -0500, useo u...@start.bg wrote: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function()) myVariable. But is there any possibility to use variables like Example myVariable? The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. If I understand you correctly, you don't want to declare the type of T when instantiating the template? This is not possible, templates must have all parameters defined at instantiation time. If you just want a shorter thing to type for Example!(void function ()), you can do: alias Example!(void function()) MyType; MyType myVariable; -Steve Yes, right, I don't want declare the template-type. Nevertheless... thanks
Re: Template for function or delegate (nothing else)
== Auszug aus bearophile (bearophileh...@lycos.com)'s Artikel useo: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function ()) myVariable. But is there any possibility to use variables like Example myVariable? D is not the SML language, templates are just placeholders. If you don't instantiate a template, you have only a symbol. Example is only assignable to an alias (and in past, to a typedef): alias Example Foo; The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. I don't yet understand what you are trying to do. Other notes: - What if your T is a functor (a callable class/struct/union instance that defined opCall)? - sizeof of a function pointer is 1 CPU word, while a delegate is 2 CPU words (and a delegate clojure has stuff on the heap too, sometimes). Bye, bearophile Idea is the following: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } void opCall() { callback(); } } other file: import example; private { Example variable; } void setExampleVariable(Example ex) { variable = ex; } void callCurrentExampleVariable() { variable(); }
core languga
Hi excuse my ignorance what does that term mean? and what the different b/w learning D pobos
Re: Invoke garbage collector?
However, I need the resources to be freed more quickly than the GC is apparently doing You could use scoped instances if you need to clean them up soon after creation.
Re: Template for function or delegate (nothing else)
On Wed, 09 Feb 2011 16:41:25 -0500, useo u...@start.bg wrote: == Auszug aus bearophile (bearophileh...@lycos.com)'s Artikel useo: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function ()) myVariable. But is there any possibility to use variables like Example myVariable? D is not the SML language, templates are just placeholders. If you don't instantiate a template, you have only a symbol. Example is only assignable to an alias (and in past, to a typedef): alias Example Foo; The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. I don't yet understand what you are trying to do. Other notes: - What if your T is a functor (a callable class/struct/union instance that defined opCall)? - sizeof of a function pointer is 1 CPU word, while a delegate is 2 CPU words (and a delegate clojure has stuff on the heap too, sometimes). Bye, bearophile Idea is the following: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } void opCall() { callback(); } } other file: import example; private { Example variable; } void setExampleVariable(Example ex) { variable = ex; } void callCurrentExampleVariable() { variable(); } I don't think you want templates. What you want is a tagged union (and a struct is MUCH better suited for this): // untested! struct Example { private { bool isDelegate; union { void function() fn; void delegate() dg; } } void setCallback(void function() f) { this.fn = f; isDelegate = false;} void setCallback(void delegate() d) { this.dg = d; isDelegate = true;} void opCall() { if(isDelegate) dg(); else fn(); } } -Steve
Re: Template for function or delegate (nothing else)
== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel On Wed, 09 Feb 2011 16:41:25 -0500, useo u...@start.bg wrote: == Auszug aus bearophile (bearophileh...@lycos.com)'s Artikel useo: I just have a problem with my variables. For example... my class/template just looks like: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } } This means that I need variables like Example!(void function ()) myVariable. But is there any possibility to use variables like Example myVariable? D is not the SML language, templates are just placeholders. If you don't instantiate a template, you have only a symbol. Example is only assignable to an alias (and in past, to a typedef): alias Example Foo; The template declaration only defines the type of a callback and perhaps one method-declaration nothing else. I already tried Example!(void*) because delegates and functions are void pointers but I always get an error. I hope there is any way to do this. I don't yet understand what you are trying to do. Other notes: - What if your T is a functor (a callable class/struct/union instance that defined opCall)? - sizeof of a function pointer is 1 CPU word, while a delegate is 2 CPU words (and a delegate clojure has stuff on the heap too, sometimes). Bye, bearophile Idea is the following: class Example(T) if (is(T == delegate) || is(T == function)) { T callback; void setCallback(T cb) { callback = cb; } void opCall() { callback(); } } other file: import example; private { Example variable; } void setExampleVariable(Example ex) { variable = ex; } void callCurrentExampleVariable() { variable(); } I don't think you want templates. What you want is a tagged union (and a struct is MUCH better suited for this): // untested! struct Example { private { bool isDelegate; union { void function() fn; void delegate() dg; } } void setCallback(void function() f) { this.fn = f; isDelegate = false;} void setCallback(void delegate() d) { this.dg = d; isDelegate = true;} void opCall() { if(isDelegate) dg(); else fn(); } } -Steve Looks really interesting and seems to work. Thanks in advance!
Re: core languga
On Wednesday, February 09, 2011 13:43:14 %u wrote: Hi excuse my ignorance what does that term mean? and what the different b/w learning D pobos ??? I think that you needed to read over that message again before sending it. It's not exactly clear. If you're asking about the term core language, that refers to the language itself rather than any of its libraries. So, if you're talking about the core language, then you're talking about the programming language itself and not any of its libraries. As for the difference between D and Phobos, D is the language, and Phobos is its standard library. You can technically use D without ever using Phobos, but most programs are likely to use Phobos, and I would expect that in the long run, it will be a very rare program indeed which doesn't use Phobos at all. Pretty much every programming language has a separation between the language itself and its standard library, but pretty much everyone uses the standard library. For instance, would you use Java without ArrayList or C++ without vector? You _can_, but most people don't. With any programming language, you have to learn the language itself to use it, and the language itself will generally lean towards certain programming paradigms and ways of doing things. On top of that, the standard library will then generally give you base functionality that most people need but isn't in the language itself, and the standard library will then tend to do things in a particular way and follow certain programming paradigms. So, if you learn to use the standard library of a language well, then you're likely to program in certain ways that you wouldn't necessarily do yourself if you just took the core language and used only your own libraries. D and Phobos are no different in that respect than any other programming language. The language itself has certain facilities that support and encourage certain ways of programming. Phobos builds on that and adds its own concepts and ways of doing things. For instance, ranges are essentially a thing of Phobos and not the language itself (though the language itself does understand them enough for you to be able to use input ranges in foreach loops). So, you could program in D just fine without knowing anything about ranges or using them at all, but if you want to use Phobos, you're likely going to have to learn about and use ranges. So, as with any programming language, if you want to be proficient in D, then you're really going to have learn both the core language and the standard library. - Jonathan M Davis
Re: Invoke garbage collector? (Scoped Instances)
== Quote from Trass3r (u...@known.com)'s article However, I need the resources to be freed more quickly than the GC is apparently doing You could use scoped instances if you need to clean them up soon after creation. To my knowledge, these are being removed from the language, and so, could only be used in the short-term.
Re: Invoke garbage collector? (Scoped Instances)
On Wednesday 09 February 2011 17:52:47 Sean Eskapp wrote: == Quote from Trass3r (u...@known.com)'s article However, I need the resources to be freed more quickly than the GC is apparently doing You could use scoped instances if you need to clean them up soon after creation. To my knowledge, these are being removed from the language, and so, could only be used in the short-term. Yes. They're inherently unsafe because of the risk of escaped references. std.typecons.scoped is intended as an alternative however, if you really want it. Personally, I'd generally advise against it unless profiling shows that you need it. - Jonathan M Davis
Re: MD5 hash on a file and rawRead
Also disregard that the error shows _libFileName, I was in the middle of refactoring so the name stayed.
Re: MD5 hash on a file and rawRead
On 2/10/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Also disregard that the error shows _libFileName, I was in the middle of refactoring so the name stayed. *I mean disregard that it's called _libFileName, when it's really filename.
[Issue 5554] New: [qtd] Covariance detection failure
http://d.puremagic.com/issues/show_bug.cgi?id=5554 Summary: [qtd] Covariance detection failure Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: samu...@voliacable.com --- Comment #0 from Max Samukha samu...@voliacable.com 2011-02-09 01:44:07 PST --- class MA { } class MB : MA { } class MC : MB { } class A { MA foo() { return null; } } interface I { MB foo(); } class B : A { override MC foo() { return null; } } class C : B, I { override MC foo() { return null; } } void main() { } Error: function test.C.foo incompatible covariant types MA() and MB() -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 1170] Cannot forward reference a type defined in a MixinStatement
http://d.puremagic.com/issues/show_bug.cgi?id=1170 Don clugd...@yahoo.com.au changed: What|Removed |Added Keywords|patch | --- Comment #9 from Don clugd...@yahoo.com.au 2011-02-09 02:53:22 PST --- I'm removing the 'patch' keyword, since even though the patches from here and from bug 102 have been applied, the original bug is not fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4112] Stride in foreach ranges
http://d.puremagic.com/issues/show_bug.cgi?id=4112 Denis Derman denis.s...@gmail.com changed: What|Removed |Added CC||denis.s...@gmail.com --- Comment #1 from Denis Derman denis.s...@gmail.com 2011-02-09 05:41:42 PST --- I'm unsure whether this is a good thing. The issue is, for me, this feature would only apply to numeric intervals (probably even only on integral ones). While the notion of by-step iteration is completely general; I guess simply orthogonal to sequence / iteration / range. Thus, I would prefere a range factory like auto byStep (R) (int step) if (...) typical use case: foreach (n ; iota(1..1000).byStep(3)) {...} or better (see http://d.puremagic.com/issues/show_bug.cgi?id=5395) foreach (n ; (1..1000).byStep(3) {...} What do you think? Negative step meaning backwards? So that we get reverse for free... An issue is, if this is not the case but negative step is intepreted literally, we get a very weird semantics compared to apparent meaning. Example for the simplest case of reverse iteration. Should iterating backwards on 0..4 (meaning 3-2-1-0) be written (more direct): foreach (n ; (0..4).byStep(-1)) (translation in the case of indices:) foreach (i ; (0..a.length).byStep(-1)) or instead (more logical but imo completely unintuitive and difficult): foreach (n ; (3..-1).byStep(-1)) (translation in the case of indices:) foreach (i ; (a.length-1..-1).byStep(-1)) By the way, this issue applies to your proposal as well: what does 1..3:-2 Actually mean? Finally, if ever we had a step syntax for i..j, I would prefere '/' than ':', read as by: foreach (; i..j:k -- traverse the interval i..j 'by' (steps of) k. Denis -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4112] Stride in foreach ranges
http://d.puremagic.com/issues/show_bug.cgi?id=4112 --- Comment #2 from Denis Derman denis.s...@gmail.com 2011-02-09 05:44:17 PST --- (Grrr! How can we edit our own posts? Could not find it.) That was supposed to be: Finally, if ever we had a step syntax for i..j, I would prefere '/' than ':', read as by: foreach (n ; i..j/k) -- traverse the interval i..j 'by' (steps of) k. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4112] Stride in foreach ranges
http://d.puremagic.com/issues/show_bug.cgi?id=4112 Andrei Alexandrescu and...@metalanguage.com changed: What|Removed |Added CC||and...@metalanguage.com --- Comment #3 from Andrei Alexandrescu and...@metalanguage.com 2011-02-09 06:11:30 PST --- (In reply to comment #2) (Grrr! How can we edit our own posts? Could not find it.) That was supposed to be: Finally, if ever we had a step syntax for i..j, I would prefere '/' than ':', read as by: foreach (n ; i..j/k) -- traverse the interval i..j 'by' (steps of) k. That's traverse the interval i..j/k. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5555] New: built-in associative array's length is nothrow
http://d.puremagic.com/issues/show_bug.cgi?id= Summary: built-in associative array's length is nothrow Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P3 Component: druntime AssignedTo: nob...@puremagic.com ReportedBy: repeate...@gmail.com --- Comment #0 from Masahiro Nakagawa repeate...@gmail.com 2011-02-09 08:35:27 PST --- I have following code: // aa is a string[string]; nothrow bool empty() const { return aa.length == 0; } I want use this code but dmd fails. Error: function hoge.Foo.empty 'empty' is nothrow yet may throw built-in AA's length() depends on _aaLen in rt/aaA.d. I think these functions should be nothrow. This issue breaks my template engine API ;( -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---