Re: [Slight OT] TDPL in Russia
Walter Bright newshou...@digitalmars.com wrote in message news:i5pl44$jf...@digitalmars.com... Michel Fortin wrote: Basically, you wanted to do what I did with my website. What was the problem exactly? Creating a style sheet that displays the contents well when read linearly? Or was it about how to trigger this particular style sheet for iPhone and iPods? The later's quite simple, just use this media attribute: media=handheld, only screen and (max-device-width: 480px) The handheld, part isn't really relevant for iOS devices, but it'll trigger the stylesheet with Opera-based handheld browsers. The problem was that I googled it and every hit used a radically different method and they'd refer to it as seems to work. I'm not comfortable using such hacks. I'd like one that officially works and is standards compliant. Then you're best off avoiding the web enitrely, or else you're in for a world of hurt ;) The web has no such things.
Re: [Slight OT] TDPL in Russia
Nick Sabalausky wrote: Walter Bright newshou...@digitalmars.com wrote in message news:i5pl44$jf...@digitalmars.com... Michel Fortin wrote: Basically, you wanted to do what I did with my website. What was the problem exactly? Creating a style sheet that displays the contents well when read linearly? Or was it about how to trigger this particular style sheet for iPhone and iPods? The later's quite simple, just use this media attribute: media=handheld, only screen and (max-device-width: 480px) The handheld, part isn't really relevant for iOS devices, but it'll trigger the stylesheet with Opera-based handheld browsers. The problem was that I googled it and every hit used a radically different method and they'd refer to it as seems to work. I'm not comfortable using such hacks. I'd like one that officially works and is standards compliant. Then you're best off avoiding the web enitrely, or else you're in for a world of hurt ;) The web has no such things. The print style sheet is standard and works great.
Re: [Slight OT] TDPL in Russia
Walter Bright newshou...@digitalmars.com wrote in message news:i5q1u1$1bf...@digitalmars.com... Sean Kelly wrote: Walter Bright Wrote: retard wrote: Thu, 02 Sep 2010 16:03:59 -0400, Nick Sabalausky wrote: J. What happens when the battery gets old and won't hold a charge? You buy a new one, of course. Why this will never happen is that once a new model of the iShit comes out, as a die hard Apple fan you simply MUST buy it and get rid of the old one. I heard they don't even replace the batteries in Apple's repair services. They just hand you a new phone. It's the subscription model for hardware. It also effectively kills the market for used iPods. Then the model is broken somewhere, because Apple hardware has an incredibly high resale value. I wouldn't buy a used ipod because of the non-replaceable battery. One has no idea how much life is left in it. I've had a number of gadgets become useless once the battery would no longer take a charge. I miss the days when there was such a thing as standard battery types. [old guy swinging a cane at some kids] Why, when *I* was a lad (*cough* *wheeze*), all the battery and device manufacturers...(*hack*)...well they got together, and they decided on what they called these standards. Yup, that was the name a' 'em (*hack* *wheeze*) And then, you could go into any store...didn't matter where ([blows nose])...and get a gadget. Any company's gadget, ain't never mattered. And when the batteries run out...well, we'd go and we'd get us s'more batteries. Yessirree. And those batteries would work with ([leans foreward]) ANYTHIN'! Ya hear me? Anythin'! Didn't matter where ya got 'em or who's name was on 'em . They'd just werk, dernnit. And you could bet on that! Yup. ([lights a pipe]) And they didn't cost no arm or leg, nether! Or void your warranty. They *made* them to werk that way. Not like you kinds these days and yer ten-packs of disposable telleyphones and single-use laptops and whatnot. Now go fetch me my pillow, boy, I'm tired!
Re: [Slight OT] TDPL in Russia
Nick Sabalausky wrote: I miss the days when there was such a thing as standard battery types. Me too. My first bad experience with custom batteries was my trusty TI SR-50A calculator, vintage 1975. After a year, it would no longer hold a charge, but I could still use it with the charger plugged in. And so I used it that way for the next 6 years or so. Then the battery got so bad even that didn't work anymore, and an EE friend of mine devised a load that behaved like a battery. I soldered that in in place of the battery, and got a few more years out of the calculator until it completely expired. Of course, this was in the years before there were desktop computers with calculator apps. Gosh I'm old! (Just for grins, I pulled it out of a drawer and plugged it in. Random led's flash. Still busted. Oh well!)
Re: [Challenge] implementing the ambiguous operator in D
== Quote from Nick Sabalausky (a...@a.a)'s article Interesting thing, but devil's advocate: What would be the uses/benefits of that versus just having for each element versions of the operators? Well the obvious benefit is that you don't have to create all those extra version -- you get them all for free. Also, ambiguous seems like a rather odd name for what it does. I don't see how ambiguity has anything to do with it. That disconnect made it difficult at first for me to understand what it was. It's more like an elementwise or something. I agree, it's a pretty bad name. I'd call it all or something.
Assigning map result, and in-place map
I'm a D n00b, so excuse my question if it is silly. I've cursorily followed D for a few years, but only now bought The D Programming Language (great book, very nicely written!) and started to really play with it. I've run into two questions which I have not been able to find the answers to online. 1) I have an int array which I want to replace elements of with compile-time string expression, e.g. i=new int[100]; auto b=map!((a==0)?42:a)(i); writeln(b); Cool, that works. But now I want to get at the resulting array. If I replace auto b with: int[] b = map ... that does not work (cannot implicitly convert expression (map(i)) of type Map!(result,int[]) to int[])... fine, but how do I get to the int[] ? 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.)
Re: Miscellaneous memory management questions
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article Peter Alexander peter.alexander...@gmail.com wrote: 1. How do I disable the GC? In a way, you don't. You can, however, replace it with a stub GC. Cool. So the stub GC does nothing and has no overhead? 4. Any plans for allocators? None of which I know. D should easily support building your own, though. Of course, such a construct would then only be supported by your own classes. That's the problem though; if I write my own allocators then no one knows about them. I won't be able to use them with the standard library, so I'll have to rewrite all parts of the standard library that allocate memory (i.e. all the containers). What's worse, if I use some other 3rd-party library then it will use it's own allocators, which will probably be incompatible with mine. The whole point of a standard library is to provide a good set of common components that application and library developers can agree to build upon. If D is supposed to be a systems programming language, then I would expect allocators to be included in the standard library. 5. Does Phobos rely on a GC? Parts of it, certainly. See above.
Re: Assigning map result, and in-place map
Bert van Leeuwen b...@e.co.za wrote in message news:i5qftb$2a2...@digitalmars.com... I'm a D n00b, so excuse my question if it is silly. I've cursorily followed D for a few years, but only now bought The D Programming Language (great book, very nicely written!) and started to really play with it. Welcome! :) I've run into two questions which I have not been able to find the answers to online. 1) I have an int array which I want to replace elements of with compile-time string expression, e.g. i=new int[100]; auto b=map!((a==0)?42:a)(i); writeln(b); Cool, that works. But now I want to get at the resulting array. If I replace auto b with: int[] b = map ... that does not work (cannot implicitly convert expression (map(i)) of type Map!(result,int[]) to int[])... fine, but how do I get to the int[] ? Instead of returning an array, map returns a range that computes the values lazily (on-demand when they're needed, instead of always computing all of them right away). This is done for performance reasons. But you can get an array with the array() function from the std.array module: auto b = array( map!((a==0)?42:a)(i) ); or auto b=map!((a==0)?42:a)(i); auto ba = array(b); BTW, instead of: map!((a==0)?42:a)(i) You can do: map!(a==0)?42:a(i) A nifty little bit of syntax sugar for when there's only one template parameter. 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I'll leave this one for someone else to answer, as I don't know whether or not something like this is already in phobos. If not, such a function can definitely be made, and maybe someone has already done so...?
Re: Assigning map result, and in-place map
On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be supported, but at least for now this works: int[] xs = [1,2,3,4,5,6,7]; copy(map!`a*a`(xs), xs); writeln(xs); [1, 4, 9, 16, 25, 36, 49]
Re: Assigning map result, and in-place map
Thanks! Nick Sabalausky Wrote: Bert van Leeuwen b...@e.co.za wrote in message news:i5qftb$2a2...@digitalmars.com... I'm a D n00b, so excuse my question if it is silly. I've cursorily followed D for a few years, but only now bought The D Programming Language (great book, very nicely written!) and started to really play with it. Welcome! :) I've run into two questions which I have not been able to find the answers to online. 1) I have an int array which I want to replace elements of with compile-time string expression, e.g. i=new int[100]; auto b=map!((a==0)?42:a)(i); writeln(b); Cool, that works. But now I want to get at the resulting array. If I replace auto b with: int[] b = map ... that does not work (cannot implicitly convert expression (map(i)) of type Map!(result,int[]) to int[])... fine, but how do I get to the int[] ? Instead of returning an array, map returns a range that computes the values lazily (on-demand when they're needed, instead of always computing all of them right away). This is done for performance reasons. But you can get an array with the array() function from the std.array module: auto b = array( map!((a==0)?42:a)(i) ); or auto b=map!((a==0)?42:a)(i); auto ba = array(b); BTW, instead of: map!((a==0)?42:a)(i) You can do: map!(a==0)?42:a(i) A nifty little bit of syntax sugar for when there's only one template parameter. 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I'll leave this one for someone else to answer, as I don't know whether or not something like this is already in phobos. If not, such a function can definitely be made, and maybe someone has already done so...?
Re: Assigning map result, and in-place map
Pelle Wrote: On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be supported, but at least for now this works: int[] xs = [1,2,3,4,5,6,7]; copy(map!`a*a`(xs), xs); writeln(xs); [1, 4, 9, 16, 25, 36, 49] Interesting. For large arrays, that seems to take almost double the time of creating a new one with array() (as in Nick's reply). So copy() obviously doesn't do it in place (not surprising given its name), and presumably makes a temporary array first from which to copy to a.
Re: Assigning map result, and in-place map
On Fri, 03 Sep 2010 14:32:47 +0400, Bert van Leeuwen b...@e.co.za wrote: Pelle Wrote: On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be supported, but at least for now this works: int[] xs = [1,2,3,4,5,6,7]; copy(map!`a*a`(xs), xs); writeln(xs); [1, 4, 9, 16, 25, 36, 49] Interesting. For large arrays, that seems to take almost double the time of creating a new one with array() (as in Nick's reply). So copy() obviously doesn't do it in place (not surprising given its name), and presumably makes a temporary array first from which to copy to a. I don't think you are right. This is how copy is defined in std.algorithm[1]: Range2 copy(Range1, Range2)(Range1 source, Range2 target) if (isInputRange!Range1 isOutputRange!(Range2, ElementType!Range1)) { for (; !source.empty; source.popFront()) { put(target, source.front); } return target; } [1] http://dsource.org/projects/phobos/browser/trunk/phobos/std/algorithm.d#L4054
Re: Assigning map result, and in-place map
On 09/03/2010 12:32 PM, Bert van Leeuwen wrote: Pelle Wrote: On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be supported, but at least for now this works: int[] xs = [1,2,3,4,5,6,7]; copy(map!`a*a`(xs), xs); writeln(xs); [1, 4, 9, 16, 25, 36, 49] Interesting. For large arrays, that seems to take almost double the time of creating a new one with array() (as in Nick's reply). So copy() obviously doesn't do it in place (not surprising given its name), and presumably makes a temporary array first from which to copy to a. Try it again with -inline. For me it's within 10% with inline, and gains even more if you add -O and -release. It also doesn't allocate, which is just a bonus. :-)
Re: Assigning map result, and in-place map
Pelle Wrote: On 09/03/2010 12:32 PM, Bert van Leeuwen wrote: Pelle Wrote: On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be supported, but at least for now this works: int[] xs = [1,2,3,4,5,6,7]; copy(map!`a*a`(xs), xs); writeln(xs); [1, 4, 9, 16, 25, 36, 49] Interesting. For large arrays, that seems to take almost double the time of creating a new one with array() (as in Nick's reply). So copy() obviously doesn't do it in place (not surprising given its name), and presumably makes a temporary array first from which to copy to a. Try it again with -inline. For me it's within 10% with inline, and gains even more if you add -O and -release. It also doesn't allocate, which is just a bonus. :-) Awesome, that made it run about 4x faster :) thanks!
Re: [Challenge] implementing the ambiguous operator in D
Philippe Sigaud philippe.sig...@gmail.com wrote: Hey, this question on SO makes for a good challenge: http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d The amb operator does this: amb([1, 2]) * amb([3, 4, 5]) == amb([3, 4, 5, 6, 8, 10]) amb([hello, world]) ~ amb([qwerty]) == amb([helloqwerty, worldqwerty]) amb([hello, world]) ~ qwerty == amb([helloqwerty, worldqwerty]) amb([hello, very long string]).length = amb([5, 16]) (I find the guy examples much more comprehensible that the articles he links to) Are people interested in trying this? Yes, very much so. However, Peter Alexander has misunderstood the ambiguous operator. The idea of amb is to return the combinatorial product of N ranges. if this sounds familiar, it is because it has been discussed at length here earlier, with me and Andrei being the prime contributors (see Combining infinite ranges and Huffman coding comparison). The solution has eluded me for a while, and I have shelved my efforts while doing other things. Perhaps now is the time to revisit it. Peter Alexander seems to have conflated the two concepts of the ambiguous operator and its require()-function. Basically, Amb should be a range of tuples, and you then filter it to retrieve the interesting parts. -- Simen
Re: [Slight OT] TDPL in Russia
On Thu, 02 Sep 2010 16:03:59 -0400, Nick Sabalausky a...@a.a wrote: Nick Sabalausky a...@a.a wrote in message news:i5ov60$2c5...@digitalmars.com... Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vieozxaleav...@localhost.localdomain... Love my iPhone. Love it. My last two phones were a Palm Treo and a Samsung touch-screen (w/stylus) smartphone with Windows mobile 6. They are absolute garbage compared to this. Granted, I started with the 3gs, and upgraded to iOS4 about a month after I got it, so my phone is the result of 3 years of polish, but I feel apple has the right focus for it. iPhone is hands down the best phone I've ever used. I thought when I got it, I would have a hard time accessing small things like the on-screen keyboard keys, but I'm surprised at how accurate I am with it, even after only having it for a few months. I regularly go to webnews on digitalmars and can click the minuscule links pretty accurately. You can not like them if you want, you are entitled to your opinion, but it seems like you have a very negative view of almost everything :) I bet your glass is half empty, huh... I'm a technical-ist: The glass is half-empty and half-full at the same time. Problem is, most glasses I've seen are only a quarter full and with overly-sweetened content (or three-quarters empty if you prefer ;) ). I just have standards. A. Search you're holding it wrong. Not a problem on my 3gs, and no longer a problem on 4 (free case). Though I understand the issue people have with the statement, Jobs is as arrogant as they come... B. Closed platforms are evil (not to be confused with closed source). s/evil/stable. It's one of the reasons my previous company was in business. They built server appliances. When you control everything on the platform, there's less things to test, less things that can go wrong, and any bugs you fix for one customer automatically translate to all other customers. C. Gatekeeping is evil. See also http://www.paulgraham.com/apple.html This I agree with. It should be enough that the developers follow the technical requirements. Still, the apps that are available are pretty cool. My new favorite is netflix. When I'm waiting for something somewhere and I can continue watching a movie I was streaming at home, that's just awesome... D. Service provider lock-in is evil. My phone works with *any* service provider (and didn't become uselessly obsolete after a year or two): http://www.uniden.com/products/productdetail.cfm?product=EXAI398 And I really do like this phone a lot. Then I guess 99% of phones are evil? I also have co-workers and friends who use jailbroken iphones on other GSM networks. I could never do that with most of my verizon phones. Besides, who switches phone service providers within the life of a phone? Not to mention that the two biggest service providers are incompatible with eachother, so you couldn't switch between them even if you wanted to. E. A die-hard Apple fan I know recently showed me his beloved iPad. Accurately setting the text-cursor was nearly impossible. But that would have been an incredibly simple fix: Use a screen that worked with a stylus or fingernail. There's millions of them out there. Even if that would have prevented multi-touch (and I don't know that it would or would not have), after using the multi-touch, I felt it added no real value other than a gee-whiz gimmick factor. Stylus/fingernail support would have added at least some real value. Your friend is doing it wrong. I can accurately set the cursor whenever I want using the magnifying glass. See an example here: http://my.safaribooksonline.com/9781430231295/typing_numbers_and_symbols F. Like all Apple software, the software on the iPad/iPhone are appallingly slim on settings/options. *shrug* Most of the settings suit me well. What options do you miss? G. A *phone* without tactile dial buttons is just plain wrong. What is it with Apple's long-standing war against tactile feedback? It detracts from usability and the only thing it adds is high-tech-gee-whiz-gimmick. What do you need tactile feedback for? You get audible feedback, and the phone number buttons are extremely responsive. Plus, if you want to dial without looking at the phone, you can use voice-activation. Blackberry tried a touch-screen with tactile feedback, it sucked. H. What's there to protect the highly-prominent screen? The screen is made of pretty durable glass. Like all touch-screen phones, it's highly advisable to get a screen protector for it. I don't get what your problem is here, do you want a screen or not? If you do, then what possible way could a manufacturer design a destruction-proof screen? Put little airbags around it in case you drop it? I. I don't give a crap how thin they can make it. But Apple seems to think I should care. Heck, I don't
Re: [OT] Dark Star (1974) - the platinum age of movies
Hello Nick, Walter Bright newshou...@digitalmars.com wrote in message news:i5pa6s$316...@digitalmars.com... Andrei Alexandrescu wrote: The scene was of the main character driving on a busy highway into a crowded metropolis. The meaning was to question the veracity and meaning of perception, existence, and human interaction - all of which are central themes in the movie. But if I showed you 15 minutes of me driving around on the freeway, you'd think I was torturing you. It's like that unauthenticated Pollock painting. If it is authenticated, it's a masterpiece. If not, it's just paint dribbled on canvas. The painting is the same in either case. Context does change things - sometimes for good reasons, sometimes for questionable reasons. Someone recently brought up the book Atlanta Nights ( http://en.wikipedia.org/wiki/Atlanta_Nights ). If I had come across that in a library a week ago, I likely would have thought What a horrid book! Terrible waste of paper. But now that I know the story behind it (it was *deliberately* bad), I find it hilarious. Another example: Back when the Jerry Maguire movie came out sometime in the 90's, one song on its soundtrack started getting played everywhere: I would walk 10,000 miles or something like that. I *hated* that song. So irritating. A few years later I found out that song was originally released in the 80's (not the 90's), made it big in Europe, but got ignored in the US until Jerry Maguire popularized it. But see, I'm a huge 80's nut. I swear, the very next time I heard the song, it didn't bother me anymore, and I actually started to like it. All that even though I knew perfectly well it was the exact same song I had hated and that the *only* thing that had changed was my knowledge of what decade it was made. It *is* an incredibly stupid phenomenon, no doubt. But it is a normal human thing, for better or worse. Venison makes really bad beef. And as long as you expect it to tates like beef it will taste bad. Same goes for most anything, if you think it's something it's not, you'll think it's a bad example of what it's not. -- ... IXOYE
Re: [Challenge] implementing the ambiguous operator in D
On 02/09/10 05:38, Philippe Sigaud wrote: Hey, this question on SO makes for a good challenge: http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d It's great to see someone doing the first D discussion topic with the [challenge] annotation. Bearophile, if you are reading this perhaps you might like to repost some of you previous challenges which have not received much attention with the [challenge] annotation in the subject line. I hope this idea of annotating ng discussion topics with their genre, say [challenge] or [trick], or perhaps [typesystem] or whatever takes on as much as [OT] threads seem to :-) Cheers Justin Johansson
Re: Bug 3999 and 4261
I just stumbled upon this in std.typecons: http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#defineEnum Might be useful from some, I guess. On Fri, Sep 3, 2010 at 7:09 AM, Don nos...@nospam.com wrote:
Re: [OT] Dark Star (1974) - the platinum age of movies
On 03/09/10 23:38, BCS wrote: Venison makes really bad beef. And as long as you expect it to tates like beef it will taste bad. Same goes for most anything, if you think it's something it's not, you'll think it's a bad example of what it's not. It's rather serendipitous that you say that as I recall a past experience. Long time ago a girlfriend once asked if I would like a coffee to which I said yes. Five minutes later she came back with the hot beverage in a cup which I then sipped and almost spit out. This was such horrid coffee. She thought she would delight me by bringing chicken noodle soup instead. However as I was expecting the taste of coffee it tasted bloody aweful. Once she explained that she was trying to delight me with something a little different for the winter's day and then I re-tasted it, with the knowledge of chicken soup in mind, it was very in fact very nice. Thirty years later I still remember what horrid coffee it was but what nice chicken soup it was also once I knew it was chicken soup. Crazy our minds can be!!! Cheers Justin Johansson
Re: The new Mono GC
This would be awesome if the Mono guys were willing to cooperate. -Craig
Re: The new Mono GC
On 02/09/10 08:03, bearophile wrote: Is it possible to try to replace (or just perform experiments) the D GC with this one? http://developers.sones.de/2010/09/01/taking-the-new-and-shiny-mono-simple-generational-garbage-collector-mono-sgen-for-a-walk/ Delegating the creation and management of the D GC to someone else (the Mono team) sounds like a possible way to have a good enough GC. Bye, bearophile Can you elucidate perhaps a little bit about the theory of the Mono GC and why it might be interesting. Some hypotheses about what makes one GC better than another would be nice topics for discussion. Cheers Justin
Re: Bug 3999 and 4261
Andrej Mitrovic: I just stumbled upon this in std.typecons: http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#defineEnum Might be useful from some, I guess. Thank you. I think std.typecons.defineEnum() may be removed. I don't think it's useful now. Bye, bearophile
[challenge] Hamming numbers
Justin Johansson: Bearophile, if you are reading this perhaps you might like to repost some of you previous challenges which have not received much attention with the [challenge] annotation in the subject line. See: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=116505 Bye, bearpophile
Re: Please comment on http://d-programming-language.org/
On 9/2/10 21:58 CDT, Boris Wang wrote: I think AA just laid emphasis on the proprietor of d language I didn't participate to the creation of the content or layout. Andrei
Re: [Challenge] implementing the ambiguous operator in D
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article Yes, very much so. However, Peter Alexander has misunderstood the ambiguous operator. Hey, I was just going by what the guy posted :) He mentioned nothing of tuples, and his examples certainly didn't show any tuples.
Re: Please comment on http://d-programming-language.org/
On 9/3/10 10:43 AM, Andrei Alexandrescu wrote: On 9/2/10 21:58 CDT, Boris Wang wrote: I think AA just laid emphasis on the proprietor of d language I didn't participate to the creation of the content or layout. Andrei Yup, I'm the guy responsible for the new design (like it or hate it), and I tried to avoid changing any content. I kept the DM logo because the original site has it. I'm fine with trying designs that emphasize D and de-emphasize Digital Mars, but I would want Walter's go-ahead first.
Re: The new Mono GC
Justin Johansson Wrote: On 02/09/10 08:03, bearophile wrote: Is it possible to try to replace (or just perform experiments) the D GC with this one? http://developers.sones.de/2010/09/01/taking-the-new-and-shiny-mono-simple-generational-garbage-collector-mono-sgen-for-a-walk/ Delegating the creation and management of the D GC to someone else (the Mono team) sounds like a possible way to have a good enough GC. Bye, bearophile Can you elucidate perhaps a little bit about the theory of the Mono GC and why it might be interesting. Some hypotheses about what makes one GC better than another would be nice topics for discussion. It sounds pretty nice, but this bullet point could be a problem: * Uses write barriers to min i mize the work done on minor collections.
Re: [challenge] Hamming numbers
bearophile wrote: Justin Johansson: Bearophile, if you are reading this perhaps you might like to repost some of you previous challenges which have not received much attention with the [challenge] annotation in the subject line. See: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=116505 Bye, bearpophile That's not a very useful problem, because the timing depends entirely on BigInt, which is completely unoptimised for small values.
Re: Bug 3999 and 4261
On 9/3/10 11:58 CDT, bearophile wrote: Andrej Mitrovic: I just stumbled upon this in std.typecons: http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#defineEnum Might be useful from some, I guess. Thank you. I think std.typecons.defineEnum() may be removed. I don't think it's useful now. Bye, bearophile Yah, that artifact predates the introspection means that make printing and parsing for enums possible. Andrei
Re: The new Mono GC
On 2010-09-03 19:58, Sean Kelly wrote: Justin Johansson Wrote: On 02/09/10 08:03, bearophile wrote: Is it possible to try to replace (or just perform experiments) the D GC with this one? http://developers.sones.de/2010/09/01/taking-the-new-and-shiny-mono-simple-generational-garbage-collector-mono-sgen-for-a-walk/ Delegating the creation and management of the D GC to someone else (the Mono team) sounds like a possible way to have a good enough GC. Bye, bearophile Can you elucidate perhaps a little bit about the theory of the Mono GC and why it might be interesting. Some hypotheses about what makes one GC better than another would be nice topics for discussion. It sounds pretty nice, but this bullet point could be a problem: * Uses write barriers to min i mize the work done on minor collections. Why would write barriers be a problem, could you elaborate? -- /Jacob Carlborg
Re: The new Mono GC
On Wed, 01 Sep 2010 18:33:40 -0400, bearophile bearophileh...@lycos.com wrote: Is it possible to try to replace (or just perform experiments) the D GC with this one? http://developers.sones.de/2010/09/01/taking-the-new-and-shiny-mono-simple-generational-garbage-collector-mono-sgen-for-a-walk/ Delegating the creation and management of the D GC to someone else (the Mono team) sounds like a possible way to have a good enough GC. license-wise, I think it would be possible to just port. The GC portion of mono is licensed via MIT X/11 It says it's semi-precise (everything except registers and stack, which are scanned conservatively). ATM, D doesn't have enough data to have precise scanning (though there is work being done on that). I don't see why it wouldn't be possible to try out this GC, it seems to be mostly usable in a D environment. -Steve
Re: [Challenge] implementing the ambiguous operator in D
On Fri, Sep 3, 2010 at 19:51, Peter Alexander peter.alexander...@gmail.comwrote: == Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article Yes, very much so. However, Peter Alexander has misunderstood the ambiguous operator. Hey, I was just going by what the guy posted :) He mentioned nothing of tuples, and his examples certainly didn't show any tuples. Yes, I agree with Peter there. As I said, I personally prefer the examples in the SO OP than the Haskell/Ruby code, if only because the example are easily understood and I find this range combinator useful in some circumstances. What we have here in D is a bit like the List monad in Haskell: a way to represent a bunch of possible values for a computation. If a can 2 or 4 or 6, and b can be 0 or 1 or 2, it makes sense for a*b to among 0,2,4,6,8,12. So thanks, Peter. But does the code compile for you? As I said, here with 2.048, it doesn't. Now, the 'real'/intriguing/mind-bending amb operator (from the 60's) does like the Haskell implementation linked in SO does: backtracking on the results to avoid some condition. If someone is up to the challenge of implementing it in D, great! Maybe with closures? I never really thought about it. I guess the D syntax would be auto x = amb([1,2,3]); auto y =amb([4,5,6]); x*y == 8; // forces desambiguation = the ambs explore the possibilities. assert(x == amb([2])); assert(y == amb([4])); There is only one value left, no more ambiguity. Maybe in this case an 'alias possibilities[0] this' could do the trick: assert(x == 2); assert(y == 4); Can we do alias someArray[0] this; ? Philippe Philippe
Re: [Challenge] implementing the ambiguous operator in D
On Fri, Sep 3, 2010 at 16:30, Justin Johansson n...@spam.com wrote: On 02/09/10 05:38, Philippe Sigaud wrote: Hey, this question on SO makes for a good challenge: http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d It's great to see someone doing the first D discussion topic with the [challenge] annotation. This was just for fun, because combining ranges is always fun, and in this case, it's a good example of operator overloading. I have a more interesting / less academic challenge in mind: make idmd, an interactive,REPL-like, D interpreter. Philippe
Re: [challenge] Hamming numbers
== Quote from Don (nos...@nospam.com)'s article That's not a very useful problem, because the timing depends entirely on BigInt, which is completely unoptimised for small values. True, but it would be nice to get it as concise as Haskell's. In an ideal world, we'd simply write it as: auto H() { return chain([BigInt(1)], setIntersection(map!2*a(H()), map!3*a(H()), map!5*a(H(; } BigInt hamming(int limit) { return H().at(limit); } But the unfortunately, due to D's type system, you cannot have recursive types (H's type depends on its own type). You should be able to get around this by introducing a abstract range wrapper. I'll see what I can come up with.
Re: [challenge] Hamming numbers
Don: That's not a very useful problem, because the timing depends entirely on BigInt, which is completely unoptimised for small values. You are usually right, but this time what you say is useless. There are other means to judge how good a program is, beside running time: - Total line count of the program; - Max amount of memory used. The Haskell version of the program is quite fast, very short, and it's lazy so it uses very low memory. The Alternate version using Cyclic Iterators Python version invented by the great Raymond Hettinger too is lazy and uses very low memory. On the other hand, that D version, that I have translated from the Java code, is eager so it uses a lot of memory, is slow (mostly because of the bigint implementation, I agree), and its source is many lines long. So D must do better along one or more than one of those axis. This huge thread shows that this is a very interesting problem, and solving it well is important for a language like that D that wants to support lazy iterables a lot in its standard library, and wants to be able to express code at a high level too (this means short programs): http://lambda-the-ultimate.org/node/608 Bye, bearophile
blosc
Something that seems fit for the D2 standard library, a lossless compressor meant to speed up some memory-heavy operations (already used in Pytables): http://blosc.pytables.org/trac Bye, bearophile
this as lvalue?
I wouldn't have thought of this representing an lvalue. However, the following absurdity compiles and executes flawlessly. Just don't uncomment the assignment to y.i! class Yikes { int i; this() { this = null; } } void main() { auto y = new Yikes(); // y.i = 0; } Is this a bug in the compiler (v.2.047)? Am I missing something in thinking it shouldn't be?
Re: [challenge] Hamming numbers
bearophile wrote: Don: That's not a very useful problem, because the timing depends entirely on BigInt, which is completely unoptimised for small values. You are usually right, but this time what you say is useless. There are other means to judge how good a program is, beside running time: - Total line count of the program; - Max amount of memory used. Well, I would hate for somebody to waste their time trying to optimise that problem either for speed or memory consumption, when both are limited by a fairly simple, short-term library issue. Lines of code, sure.
Re: Please comment on http://d-programming-language.org/
How is the website programmed? If done properly the page content is independent of the style. Use page templates and CSS stylesheets so that you have a single point of change for the entire website. Stay away from static HTML files. Use PHP, JSP, Freemarker or something similar. Using stylesheets can allow your users to view the site however is most pleasing to them. For example. Go to this page: http://www.thesitewizard.com/css/switch-alternate-css-styles.shtml and then in FireFox select: View- Page Style and switch between the two provided styles. Neato! If you want my opinion on the visual style I'd say it's a huge improvement over the digital mars site. The flare gives it a sophisticated feel. However, please don't let trivial matters like the look of the site slow us down from getting accurate and useful information out to the world. If you have a single point of change the look can be tweaked as time goes on. In terms of layout I agree with filgood that a site like http://fantom.org/is a better model. It has the most important links in BIG colorful text on the home page: 1) What is D? 2) What does it look like? 3) How do I download it? With a site like fantom.org you can tell that somebody sat down and though out: What's really important to my users? What are the primary use-cases of my visitors? My 2cents. I'd be glad to help if you need it. - Adam
Re: [Slight OT] TDPL in Russia
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vigl6wxpeav...@localhost.localdomain... On Thu, 02 Sep 2010 16:03:59 -0400, Nick Sabalausky a...@a.a wrote: Nick Sabalausky a...@a.a wrote in message news:i5ov60$2c5...@digitalmars.com... B. Closed platforms are evil (not to be confused with closed source). s/evil/stable. It's one of the reasons my previous company was in business. They built server appliances. When you control everything on the platform, there's less things to test, less things that can go wrong, and any bugs you fix for one customer automatically translate to all other customers. In theory. In practice, I really don't believe it's quite so simple. And there's still the ethical issue. D. Service provider lock-in is evil. My phone works with *any* service provider (and didn't become uselessly obsolete after a year or two): http://www.uniden.com/products/productdetail.cfm?product=EXAI398 And I really do like this phone a lot. Then I guess 99% of phones are evil? 99% of phones? Certainly not. 99% of *cell* phones? Absolutely, yes. Service provider lock-in is one of the primary reasons I've never bought one. I also have co-workers and friends who use jailbroken iphones on other GSM networks. In an allegedly capitalist society (or mixed-economy with capitalist leanings as the case may be), no one should ever have any reason to devise or use such hacks for such a basic freedom as consumer choice. I could never do that with most of my verizon phones. Verizon is one of the worst cell companies out there anyway. Besides, who switches phone service providers within the life of a phone? No one, but you're overlooking the *reasons* that doesn't happen: contract lock-in and hardware that's not built to last. Not to mention that the two biggest service providers are incompatible with eachother, so you couldn't switch between them even if you wanted to. If there's a fundamental difference in protocols (as opposed to the artificially-created incompatibilities), then yes, of course that's fine. However, outside the cell phone world, such situations are likely to result in dual-use devices: DVD-R and DVD+R were incompatible, but both widely used. So instead of going the absolutely idiotic cell-phone route of *maintaining* a dividing chasm, they just made devices support both. And I don't believe extra cost is necessarily a good argument against this practice, because of how quickly dual+/- DVD player/burner prices became dirt cheap. E. A die-hard Apple fan I know recently showed me his beloved iPad. Accurately setting the text-cursor was nearly impossible. But that would have been an incredibly simple fix: Use a screen that worked with a stylus or fingernail. There's millions of them out there. Even if that would have prevented multi-touch (and I don't know that it would or would not have), after using the multi-touch, I felt it added no real value other than a gee-whiz gimmick factor. Stylus/fingernail support would have added at least some real value. Your friend is doing it wrong. Well, I was the one using it and noticing that. I can accurately set the cursor whenever I want using the magnifying glass. See an example here: http://my.safaribooksonline.com/9781430231295/typing_numbers_and_symbols That's nothing more than a workaround. How is that *not* worse than being able to just use the tip of your fingernail? F. Like all Apple software, the software on the iPad/iPhone are appallingly slim on settings/options. *shrug* Most of the settings suit me well. What options do you miss? I admit, I don't remember and I'd have to use it more to see. But I have spent a fair amount of time with other Apple products. I even used OSX as my primary system for about a year or two. And (aside from the Apple II, which obviously doesn't quite count) there has never been a piece of Apple software I've used more than a little for which I haven't found large amounts of things that would be ideal as setting or even obvious as settings but were sorely lacking. Same goes for features (such as the iPod/iTunes's inexcusable lack of Vorbis support, and for a *long* time iTunes couldn't read CD audio if track 1 was data (which was not entirely uncommon) but everything else could). So judging by the very sparse options on the iPad, I have fairly strong reason to believe it would be the same. G. A *phone* without tactile dial buttons is just plain wrong. What is it with Apple's long-standing war against tactile feedback? It detracts from usability and the only thing it adds is high-tech-gee-whiz-gimmick. What do you need tactile feedback for? See, now I just can't even fathom that kind of stance, so it's difficult for me to argue against it. For me it's just a fundamental thing: With tactile feedback without tactile feedback, by a large degree. You get audible feedback, and the phone
Re: [challenge] Hamming numbers
Don: Well, I would hate for somebody to waste their time trying to optimise that problem either for speed or memory consumption, when both are limited by a fairly simple, short-term library issue. What is the short-term Phobos issue that limits the memory usage? In the current Phobos2 I have not found any easy-to-use mean to transform that eager D version into a lazy version that uses about 1/10 of the memory it currently uses (s in the second Python version). Bye, bearophile
Re: this as lvalue?
JMRyan: Is this a bug in the compiler (v.2.047)? Am I missing something in thinking it shouldn't be? I think it's not a bug. It's not a common need, but a method may way want to swap this with another. In Phobos this is done on a struct, see: http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d#L324 Bye, bearophile
Re: this as lvalue?
On Friday 03 September 2010 13:22:51 JMRyan wrote: I wouldn't have thought of this representing an lvalue. However, the following absurdity compiles and executes flawlessly. Just don't uncomment the assignment to y.i! class Yikes { int i; this() { this = null; } } void main() { auto y = new Yikes(); // y.i = 0; } Is this a bug in the compiler (v.2.047)? Am I missing something in thinking it shouldn't be? Of course, this is an lvalue. 1. Think about a struct for a moment, rather than a class. It's a value type. Assigning to this inside a struct would change the struct's value. In some circumstances, it would make perfect sense to do this. Assigning it to the struct's init property to reset it would be a prime example. 2. Think about what a member function _really_ looks like. The member function printM() in this class here class A { int _x; void printMe() { writeln(x); } } really looks like this void printMe(A this, printMe()) { writeln(this.x); } If you were to set this to null in printMe(), what would it do? Nothing. You just set a function parameter to null. Sure, after that, this be null _within that function_, but it shouldn't be null after that that because the actual object that this points to still exists, and when its reference gets passed to other member functions, those won't be null, because you just set the local variable to null. For instance, this program runs just fine: import std.stdio; class A { int _x; this(int x) { _x = x; } void print() { writeln(_x); } void nullifyMe() { this = null; } } void main() { auto a = new A(13); a.print(); a.nullifyMe(); a.print(); } It prints 13 13 Now, _your_ program bombs. However, I believe that that's because you assigned null to this in the _constructor_. My guess is that internally, your constructor looks something like this: Yikes this(Yikes this) { this = null; return this; } When this is called, its member variables (namely i) have been initialized, and its initial state is passed to the constructor to further do whatever stuff that you want your constructor to do. It then likely return null, which is what you get from new() and is what is assigned to your local variable y. So, y is then null. The Yikes object that you just created still exists. It's floating around in memory. It's just that you can't get at it. If you try this instead: import std.stdio; Yikes global; class Yikes { int i; this() { global = this; this = null; } } void main() { auto y = new Yikes(); global.i = 1; writeln(global.i); } it works and prints 1. You could even get rid of the auto y = part. So, this is most definitely an lvalue. It's a bit stupid to assign null to it - especially in the constructor - but it makes perfect sense that it works. And in some circumstances, it makes perfect sense to do so (though not with classes since all it would ever affect would be the local variable and any member functions that called from that member function). - Jonathan M Davis
Re: this as lvalue?
On 9/3/10 16:03 CDT, bearophile wrote: JMRyan: Is this a bug in the compiler (v.2.047)? Am I missing something in thinking it shouldn't be? I think it's not a bug. It's not a common need, but a method may way want to swap this with another. In Phobos this is done on a struct, see: http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d#L324 Bye, bearophile For classes this must be an rvalue. Andrei
Re: this as lvalue?
On Friday 03 September 2010 14:22:46 Andrei Alexandrescu wrote: On 9/3/10 16:03 CDT, bearophile wrote: JMRyan: Is this a bug in the compiler (v.2.047)? Am I missing something in thinking it shouldn't be? I think it's not a bug. It's not a common need, but a method may way want to swap this with another. In Phobos this is done on a struct, see: http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d# L324 Bye, bearophile For classes this must be an rvalue. Andrei There is no value in this being assignable in a class, but at the lower level of how the functions are actually declared underneath (with them taking this as an argument), it makes perfect sense that it would work. It certainly wouldn't be bad to disallow it though, since it's pointless and is just going to cause bugs, though generally not as bad as the ones in the OP's example (since he assigned to this in the constructor). Still, I don't know how you could make it a true rvalue. You'd need the ability to pass a const reference to non-const data to do that, and D doesn't allow for that. The invisible this parameter, being a reference, is going to suffer from all of the issues with const that have been oft-discussed (though, generally what people want is a non-const reference to const data rather than a const reference to non-const data like you would need for this). - Jonathan M Davis
32-bit Memory Limitations
Hello all- I apologize since I'm sure this question has been asked numerous times previous, but I could not find it in the last 10k messages. Is there a rough time line for 64-bit DMD 2 support? (For Linux--I don't care about Windows.) I understand that Walter is working on it and certainly don't expect a firm date, but I have no sense for the amount of work involved... Is this a one man-week feature or several man-months? I know GDC has 64-bit support, but it has not been synced up in some time. Does anyone know if this will be updated in the near future. I ask because I have written a scientific application I would like to operate on a very large matrix of doubles--in the range of 200^4 elements-- requiring about 12GB of memory, far larger than the current ~4GB limit. Ideally, I'd like to ramp this up to even 20GB matrices. I'm currently running on machines with 24GB of RAM (and we may upgrade a few next year) so this is not a performance issue, merely a software issue. Additionally, is anyone aware of any extreme cleverness to transparently work around this issue? I would imagine not, but I'm constantly amazed by some of the hacks I've seen. 4GB limits me to about 150^4 elements, which is acceptable for the time being. As such, I'm not terribly interested in any extreme hacks to get around this. I could obviously multi-process the computation (which would help in distributing it) but I don't need to do this yet. (Yes, all of those exponents are 4, not 2. This is actually a 4 dimensional matrix, but for the purpose of most parts of the computation, I can treat it like a typical 2-dim matrix. Not relevant, I suppose, but perhaps interesting.) ~John
Re: this as lvalue?
On 9/3/10 16:33 CDT, Jonathan M Davis wrote: Still, I don't know how you could make it a true rvalue. It's very simple - make this the result of a hypothetical function call. Andrei
Re: The new Mono GC
Jacob Carlborg Wrote: On 2010-09-03 19:58, Sean Kelly wrote: It sounds pretty nice, but this bullet point could be a problem: * Uses write barriers to min i mize the work done on minor collections. Why would write barriers be a problem, could you elaborate? I think write barriers in this context are calls out to the GC to notify it of reference changes, and these are generated by the compiler. A language like D that can call inline ASM, external C routines, etc, simply can't provide that guarantee. SafeD maybe.
Re: Please comment on http://d-programming-language.org/
On 9/3/10 1:31 PM, Adam B wrote: How is the website programmed? If done properly the page content is independent of the style. Use page templates and CSS stylesheets so that you have a single point of change for the entire website. Stay away from static HTML files. Use PHP, JSP, Freemarker or something similar. Sorry, I think it's going to stay static HTML: the website is generated using DDoc macros and I believe Walter is unlikely to want to go in any other direction. Using stylesheets can allow your users to view the site however is most pleasing to them. For example. Go to this page: http://www.thesitewizard.com/css/switch-alternate-css-styles.shtml and then in FireFox select: View- Page Style and switch between the two provided styles. Neato! If you want my opinion on the visual style I'd say it's a huge improvement over the digital mars site. The flare gives it a sophisticated feel. However, please don't let trivial matters like the look of the site slow us down from getting accurate and useful information out to the world. If you have a single point of change the look can be tweaked as time goes on. I haven't been changing the content--indeed I have purposely stayed away from doing so. I believe that the desired direction is to get a good look and feel working independently of the content, and the content can be modified independently of my changes. I do have some thoughts on what kind of content changes I'd like to see, though. In terms of layout I agree with filgood that a site like http://fantom.org/ is a better model. It has the most important links in BIG colorful text on the home page: 1) What is D? 2) What does it look like? 3) How do I download it? With a site like fantom.org http://fantom.org you can tell that somebody sat down and though out: What's really important to my users? What are the primary use-cases of my visitors? My 2cents. I'd be glad to help if you need it. - Adam If you or anyone else is interested in hacking at my look and feel please let me know and I can send you a .zip of the DDoc source code with my changes. If you want to hack at the original DDoc files without my changes they're in the Phobos repository at http://www.dsource.org/projects/phobos/browser/trunk/docsrc
Re: [Slight OT] TDPL in Russia
On Fri, 03 Sep 2010 16:36:55 -0400, Nick Sabalausky a...@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message Then I guess 99% of phones are evil? 99% of phones? Certainly not. 99% of *cell* phones? Absolutely, yes. Service provider lock-in is one of the primary reasons I've never bought one. Yes, that's what I meant :) I thought we were talking cell phones here... And OMG, you've never bought a cell phone? Why are you punishing yourself ;) I suppose with the attitude you have towards them it would just raise your blood pressure carrying it around... Your lack of experience with cell phones does not give any boost to your position... I also have co-workers and friends who use jailbroken iphones on other GSM networks. In an allegedly capitalist society (or mixed-economy with capitalist leanings as the case may be), no one should ever have any reason to devise or use such hacks for such a basic freedom as consumer choice. Huh? Why should verizon go out of its way to allow you to use its phones with other services? Maybe you don't understand capitalism... I could never do that with most of my verizon phones. Verizon is one of the worst cell companies out there anyway. [purposely ignoring] Besides, who switches phone service providers within the life of a phone? No one, but you're overlooking the *reasons* that doesn't happen: contract lock-in and hardware that's not built to last. Contract lock-in only happens if you want to buy a phone cheap. If you absolutely don't want a 2-yr contract, you can pay full price for the phone. These days, hardware is not built to last no matter what it is. And it's because people don't *want* old hardware. As a manufacturer, you have a choice: 1. build something that's more expensive, but outlasts its usefulness or 2. build something that's cheaper, may not last as long, but lasts at least until the next gen version is available. And I like to buy things once and keep them as long as possible (my stereo has an input for laser disc to give you an idea). But cell phones and computers change so fast that the hardware is obsolete before it's broken. Not to mention that the two biggest service providers are incompatible with eachother, so you couldn't switch between them even if you wanted to. If there's a fundamental difference in protocols (as opposed to the artificially-created incompatibilities), then yes, of course that's fine. Yes, Verizon uses CDMA and ATT uses GSM. Different protocols, different chips required. However, outside the cell phone world, such situations are likely to result in dual-use devices There were some phones like that. Nobody cared ;) E. A die-hard Apple fan I know recently showed me his beloved iPad. Accurately setting the text-cursor was nearly impossible. But that would have been an incredibly simple fix: Use a screen that worked with a stylus or fingernail. There's millions of them out there. Even if that would have prevented multi-touch (and I don't know that it would or would not have), after using the multi-touch, I felt it added no real value other than a gee-whiz gimmick factor. Stylus/fingernail support would have added at least some real value. Your friend is doing it wrong. Well, I was the one using it and noticing that. I can accurately set the cursor whenever I want using the magnifying glass. See an example here: http://my.safaribooksonline.com/9781430231295/typing_numbers_and_symbols That's nothing more than a workaround. How is that *not* worse than being able to just use the tip of your fingernail? Because... it's better? At least I think it is :) What if you don't have a long fingernail? Even if you do have a fingernail, and are using an old-style screen that could detect the fingernail, it's probably going to be more inaccurate, and without a way to tune into the right position. I've had two old-style touch screen phones before this. They suck. They break, require calibration, and require a stylus. My samsung phone got to be so inaccurate that I pretty much avoided using the touch screen as much as possible. I'll pay the price of lost accuracy when positioning a cursor in order to avoid having to pop out a stylus to press on-screen buttons. And once you get used to it (the cursor positioning), it's fast. G. A *phone* without tactile dial buttons is just plain wrong. What is it with Apple's long-standing war against tactile feedback? It detracts from usability and the only thing it adds is high-tech-gee-whiz-gimmick. What do you need tactile feedback for? See, now I just can't even fathom that kind of stance, so it's difficult for me to argue against it. For me it's just a fundamental thing: With tactile feedback without tactile feedback, by a large degree. ok then :) You get audible feedback, and the phone number buttons are extremely responsive.
Re: this as lvalue?
On Friday 03 September 2010 14:38:27 Andrei Alexandrescu wrote: On 9/3/10 16:33 CDT, Jonathan M Davis wrote: Still, I don't know how you could make it a true rvalue. It's very simple - make this the result of a hypothetical function call. Andrei Ah, that would do it. Though you wouldn't want to _actually_ do that in the generated code given how poor the inliner is. - Jonathan M Davis
Re: 32-bit Memory Limitations
John Demme: Is this a one man-week feature or several man-months? I think few Walter-months. Each Walter-month is about three human-months ;-) Bye, bearophile
Re: this as lvalue?
Andrei Alexandrescu: For classes this must be an rvalue. OK. Why? Bye, bearophile
Re: 32-bit Memory Limitations
On 9/3/10 17:10 CDT, bearophile wrote: John Demme: Is this a one man-week feature or several man-months? I think few Walter-months. Each Walter-month is about three human-months ;-) Should be quicker than that. I think we'll have something usable before the end of this month. Walter wanted to get to alpha in August, but was detoured by work on optlink. Andrei
Re: this as lvalue?
On 9/3/10 17:16 CDT, bearophile wrote: Andrei Alexandrescu: For classes this must be an rvalue. OK. Why? If you could change this from within a method you'd pretty much ruin everything about object orientation. Andrei
Re: [Slight OT] TDPL in Russia
On 9/3/10 16:51 CDT, Steven Schveighoffer wrote: Well, it's just that they haven't got to it yet, or maybe they don't feel it's as important as other issues. If something is 99% perfect and you want to point out the 1%, I guess you're entitled to it. But if everything else out there is only 90% perfect, then it's just pointless griping. It's a phone, it calls just fine (best in-call interface by far I've seen), it surfs the internet very well (best web browser experience on a phone I've had by far), and has lots of attention to detail. The frilly petty stuff isn't what makes the phone bad or good. My opinion is that the obvious stuff *does* work well, it's the niche stuff that has issues, and they are issues I'm willing to live with. I totally agree. Before the iPhone, I'd always complained that cell phones were designed by villains who made them tedious to use on purpose. When criticizing it's always good to keep in mind what baseline we're talking about. Andrei
[OT] Use case for a 4-D matrix
Dnia 03-09-2010 o 23:37:18 John Demme j...@cs.columbia.edu napisał(a): (Yes, all of those exponents are 4, not 2. This is actually a 4 dimensional matrix, but for the purpose of most parts of the computation, I can treat it like a typical 2-dim matrix. Not relevant, I suppose, but perhaps interesting.) Very. What you do with 4-D matrices? Tell us! Tomek
Re: this as lvalue?
On Friday 03 September 2010 15:18:25 Andrei Alexandrescu wrote: On 9/3/10 17:16 CDT, bearophile wrote: Andrei Alexandrescu: For classes this must be an rvalue. OK. Why? If you could change this from within a method you'd pretty much ruin everything about object orientation. Andrei On the bright side, except for the constructor, it should only change what happens in that one member function and anything member functions that are called from it (or called from something that's called from it), so it's not like it's going to break everything. But really, it shouldn't work. There's no value to it. It just allows for bugs, even if you have to work at it to get them. I'm 99% certain that you can't reassign this in C++, C#, or Java, and I'd sooner expect someone to be surprised that it's possible that actually want to be able to. It's useful for structs, but for classes, it has no value. And as you say, it effectively breaks object orientation. - Jonathan M Davis
Re: [Challenge] implementing the ambiguous operator in D
Peter Alexander peter.alexander...@gmail.com wrote: == Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article Yes, very much so. However, Peter Alexander has misunderstood the ambiguous operator. Hey, I was just going by what the guy posted :) He mentioned nothing of tuples, and his examples certainly didn't show any tuples. Sorry, yes. Copied the wrong name off of the OP on SO. Should have said chrisdew, not Peter Alexander. -- Simen
Re: [Challenge] implementing the ambiguous operator in D
Philippe Sigaud philippe.sig...@gmail.com wrote: Now, the 'real'/intriguing/mind-bending amb operator (from the 60's) does like the Haskell implementation linked in SO does: backtracking on the results to avoid some condition. If someone is up to the challenge of implementing it in D, great! Maybe with closures? I never really thought about it. I guess the D syntax would be auto x = amb([1,2,3]); auto y =amb([4,5,6]); x*y == 8; // forces desambiguation = the ambs explore the possibilities. I believe this will only work with arrays as input. Either that, or I need a way to make this work: struct Foo( R ) if ( isForwardRange!R ) { bool delegate( ElementType!R ) bar; Filter!( bar, R ) range; } Or, well, something like it. I need a static type for a Filter that delegates to a struct member, in this case bar. assert(x == amb([2])); assert(y == amb([4])); There is only one value left, no more ambiguity. Maybe in this case an 'alias possibilities[0] this' could do the trick: assert(x == 2); assert(y == 4); Can we do alias someArray[0] this; ? For a simple assert like that, overloading opEquals ought to do the trick, no? -- Simen
Re: [Challenge] implementing the ambiguous operator in D
Simen kjaeraas simen.kja...@gmail.com wrote: I believe this will only work with arrays as input. Either that, or I need a way to make this work: struct Foo( R ) if ( isForwardRange!R ) { bool delegate( ElementType!R ) bar; Filter!( bar, R ) range; } Or, well, something like it. I need a static type for a Filter that delegates to a struct member, in this case bar. I would have thought this'd work, but apparently I'm wrong: module foo; import std.stdio; import std.algorithm; import std.range; struct Foo( R ) if ( isForwardRange!R ) { R range; void delegate( ) _popFront; bool delegate( ) _empty; ElementType!R delegate( ) _front; this( R rng ) { range = rng; _popFront = { range.popFront( ); }; _empty = { return range.empty; }; _front = { return range.front; }; } void attempt( bool delegate( ElementType!R ) dg ) { auto rng = filter!dg( range ); _popFront = { rng.popFront( ); }; _empty = { return rng.empty; }; _front = { return rng.front; }; } void popFront( ) { _popFront( ); } @property bool empty( ) { return _empty( ); } @property ElementType!R front( ) { return _front( ); } } Foo!R bar( R )( R rng ) if ( isForwardRange!R ) { return Foo!R( rng ); } void main() { auto b = bar( [1,2,3] ); foreach ( e; b ) { writeln( e ); } } Output: 1 object.Error: Access Violation -- Simen
Re: [OT] Use case for a 4-D matrix
Hello Tomek, Dnia 03-09-2010 o 23:37:18 John Demme j...@cs.columbia.edu napisał(a): (Yes, all of those exponents are 4, not 2. This is actually a 4 dimensional matrix, but for the purpose of most parts of the computation, I can treat it like a typical 2-dim matrix. Not relevant, I suppose, but perhaps interesting.) Very. What you do with 4-D matrices? Tell us! http://en.wikipedia.org/wiki/Tensor#Continuum_mechanics FEA on elastic solids? Tomek -- ... IXOYE
Re: [Slight OT] TDPL in Russia
Hello Walter, Michel Fortin wrote: Basically, you wanted to do what I did with my website. What was the problem exactly? Creating a style sheet that displays the contents well when read linearly? Or was it about how to trigger this particular style sheet for iPhone and iPods? The later's quite simple, just use this media attribute: media=handheld, only screen and (max-device-width: 480px) The handheld, part isn't really relevant for iOS devices, but it'll trigger the stylesheet with Opera-based handheld browsers. The problem was that I googled it and every hit used a radically different method and they'd refer to it as seems to work. I'm not comfortable using such hacks. I'd like one that officially works and is standards compliant. Setup a mobile.digitalmars.com that has hosts the same files as www.* but a different .css? A little work with the config files and you might even need only one copy of the files on the server. -- ... IXOYE
Re: Logger For D Design Doc
Apologies, but it appears I left in a section I should have removed...ignore the NOTES section that contains a bulleted list. The rest of the document describes everything in that list in better detail. Casey
Logger For D Design Doc
Hello, As promised, I took some time to create a small document (just a text file) to describe a potential logger for D. Glog was a major influence on how the design turned out, though there are some differences. Please note it's not a 100% solution yet. Hopefully this is closer to what Andrei is looking for. All I ask is that those that are interested in this please take your time when looking this over before responding and please do ask questions, comments, etc. Thanks and enjoy! Casey Logger for D Design ARCHITECTURE The logger will consist of three distinct components: 1) A public interface to allow a user to write messages to a log. 2) A background thread to periodically poll the configuration file for changes. 3) A writer thread that handles the actual writing of log messages to some location. The writer thread is the most interesting as it will support being able to use a user-defined log writer method that conforms to a specific interface. At least one log writer will be provided by default, therefore this is not needed. The reason for this capability is not only to make it easier to add different writers in the future, but to remain flexible. Individuals may require a custom solution, such as logging to a database or a custom file format. The current plan is to store function pointers in an associative array. A mixin will be provided that accepts an ID/name for the function and a pointer to the function. The function can then be specified in the configuration file. Also, it is expected that any writer can be configured using the same configuration file. INITIALIZATION -- Some basic initialization needs to occur for the logger to work. This is because two threads are spawned in the background and I also want to capture the location where the logging is occurring. There are two possible techniques for each. Thread Initialization - The first method, and probably the most desirable, is to have thread initialization occur using a static constructor. This way the user does not have to ensure that it was done before using the logger. This should be very feasible as the constructor would be part of the class that does the log writing, which would be used by the methods described below under LOGGING. E.g. a simplified version of the log function could look like this: void log(enum level, string msg) { logWriter.writeToLog(level, msg); } The second method is the one currently used, which is to have the user call a constructor and the constructor starts the threads. Logger Initialization - If a constructor is explicitly called, then the location where the logging is occurring can be passed in as a parameter. However, it appears that the more desirable way to do this is using a mixin. This way, we can use __FILE__ as the default. Unfortunately, it means that something similar to this needs to appear in the code: mixin(initLogger!()) The location is important as it lets the user know where a log message originated from. However, it is a pain to have to include it in every log message, therefore being able to have it set once in a module/class ensures we get this information without being a chore. Note: If mixins could be called like normal functions, this could be even cleaner as the log statements could possibly be mixins. However, having a person do this every time seems very ugly: mixin(log!(INFO, ...)); The big question here is whether a mixin, or mixin template, can be used as a Variadic Template. LOGGING --- The current plan is to have all logging statements look similar to this: log(INFO, some message, 91, foo); logf(DEBUG, %s - %d, Current value, 57); logc((a b), TRACE, 'a' should not be greater than 'b'); logcf((a % 10 == 0), INFO, %s - %d, current count, count); However, if we go with a class-based approach, then they would look more like this: logger.log(INFO, some message, 91, foo); Aliases can then be used to make them look like this: logger.INFO(some message, 91, foo); Writing to the log -- Each of these methods are simply wrappers around the log writer function. These wrappers are responsible for checking the current log level and any user-provided boolean conditions to determine if logging should occur. If logging is to occur, then the message is passed to the log writer. Writing to the log will be done by sending messages to a writer thread. This was done primarily to support applications that use multiple threads, however it also helps ensure that logging has a minimal impact on the normal operation of a program. NOTE: Need to determine if send/receive support variadic parameters. If not, all formatting will need to be done before passing the message to the log writer. If it is possible, formatting can be performed in the log writer and help keep the logging overhead from impacting program execution. Buffered vs. Unbuffered Writes
Re: [Slight OT] TDPL in Russia
BCS wrote: Setup a mobile.digitalmars.com that has hosts the same files as www.* but a different .css? A little work with the config files and you might even need only one copy of the files on the server. That might work.
Re: [OT] Dark Star (1974) - the platinum age of movies
On 02/09/2010 22:30, bearophile wrote: BLS: But if you like SF, buy the book from Stanislaw Lem. IMO the best SF author and philosopher ever. The SF author I like most is Greg Egan. Any group of ten of his short stories contain more ideas than the whole career of an average SF author :-) Bye, bearophile Thanks, Is there a book you would recommend from Greg Egan ? To be honest with you I have never heard about him.
Re: [Slight OT] TDPL in Russia
Nick Sabalausky wrote: But I have spent a fair amount of time with other Apple products. I even used OSX as my primary system for about a year or two. And (aside from the Apple II, which obviously doesn't quite count) there has never been a piece of Apple software I've used more than a little for which I haven't found large amounts of things that would be ideal as setting or even obvious as settings but were sorely lacking. Same goes for features (such as the iPod/iTunes's inexcusable lack of Vorbis support, and for a *long* time iTunes couldn't read CD audio if track 1 was data (which was not entirely uncommon) but everything else could). So judging by the very sparse options on the iPad, I have fairly strong reason to believe it would be the same. Yeah, I'm mystified by some of this stuff, too. Like why WMP will not recognize CDTEXT info. (I sent them a bug report on it 5 years ago at least.) Like how FLAC format does not allow for track info - you have to have a separate cue file for that. Yee gawds. The image convert program on Linux to convert between audio formats loses the tag information in the process.
Re: [Slight OT] TDPL in Russia
I'm pretty sure that's only for albums which are stored as a single flac file. They usually come with a .cue file which stores track lengths so you can split up the huge flac file into each track as a flac. Then you can have per-track info stored in the flac files themselves. As for splitting a .flac file that has a .cue file, Medieval cue splitter is probably the best free tool for the job. On Sat, Sep 4, 2010 at 3:36 AM, Walter Bright newshou...@digitalmars.com wrote: Like how FLAC format does not allow for track info - you have to have a separate cue file for that.
Re: [OT] Dark Star (1974) - the platinum age of movies
BLS: Thanks, Is there a book you would recommend from Greg Egan ? To be honest with you I have never heard about him. Greg Egan is exceptionally good and he invents some of the most incredible ideas, but he's not for everyone. He writes the hardest SF. So if you don't like scientifically accurate SF, then Greg Egan isn't for you. I have read all novels and short stories he has written (but the last one, Zendegi, I will eventually read it too). As it happens with most other SF writers, his books are not fully separated from each other even if no characters last more than a book, there is a development in the author ideas. So I suggest you to start from the first books and short story collections he has written, in chronological order. On the author site (and elsewhere on the net) you find many (probably 15 short stories or so), so even if you don't read them in chronological order, you will be able to know if you want to read his books. http://gregegan.customer.netspace.net.au/ http://en.wikipedia.org/wiki/Greg_Egan I have written several short stories inspired by ideas or stories invented by Greg Egan. I think you will need to wait 20-40 more years before some movie starts to copy from his ideas (typically in a bad way, see the last movies based on Asimov novels, like I robot, Bicentary man, etc. The movie on I robot tells even the opposite of the purpose those short stories were written for). Bye, bearophile
Re: [Slight OT] TDPL in Russia
It still makes no sense to have it as a separate file. Andrej Mitrovic wrote: I'm pretty sure that's only for albums which are stored as a single flac file. They usually come with a .cue file which stores track lengths so you can split up the huge flac file into each track as a flac. Then you can have per-track info stored in the flac files themselves. As for splitting a .flac file that has a .cue file, Medieval cue splitter is probably the best free tool for the job. On Sat, Sep 4, 2010 at 3:36 AM, Walter Bright newshou...@digitalmars.com wrote: Like how FLAC format does not allow for track info - you have to have a separate cue file for that.
Re: The new Mono GC
Sean Kelly wrote: I think write barriers in this context are calls out to the GC to notify it of reference changes, and these are generated by the compiler. A language like D that can call inline ASM, external C routines, etc, simply can't provide that guarantee. SafeD maybe. Such write barriers are a performance problem, too.
Re: 32-bit Memory Limitations
Excellent. Thanks very much. Andrei Alexandrescu wrote: On 9/3/10 17:10 CDT, bearophile wrote: John Demme: Is this a one man-week feature or several man-months? I think few Walter-months. Each Walter-month is about three human-months ;-) Should be quicker than that. I think we'll have something usable before the end of this month. Walter wanted to get to alpha in August, but was detoured by work on optlink. Andrei
Re: SO rotate question
On 09/02/2010 10:24 PM, bearophile wrote: simendsjo: Suggestions for D-ifying the code is welcome. Your unit tests are not good enough, they miss some important corner cases. This my first version in D2: import std.string: indexOf; /// return True if s1 is a rotated version of s2 bool isRotated(T)(T[] s1, T[] s2) { return (s1.length + s2.length == 0) || (s1.length == s2.length indexOf(s1 ~ s1, s2) != -1); } unittest { // of isRotated assert(isRotated(, )); assert(!isRotated(, x)); assert(!isRotated(x, )); assert(isRotated(x, x)); string s = rotato; assert(isRotated(s, rotato)); assert(isRotated(s, otator)); assert(isRotated(s, tatoro)); assert(isRotated(s, atorot)); assert(isRotated(s, torota)); assert(isRotated(s, orotat)); assert(!isRotated(s, rotator)); assert(!isRotated(s, rotat)); assert(!isRotated(s, rotata)); } void main() {} Bye, bearophile This is what I wrote: bool isRotated(T)(T[] a, T[] b) { return a.length == b.length (a.length == 0 || canFind(chain(a,a), b)); } Use chain to avoid allocation. canFind isn't really the best possible name, is it?
Re: SO rotate question
Pelle wrote: On 09/02/2010 10:24 PM, bearophile wrote: simendsjo: Suggestions for D-ifying the code is welcome. Your unit tests are not good enough, they miss some important corner cases. This my first version in D2: import std.string: indexOf; /// return True if s1 is a rotated version of s2 bool isRotated(T)(T[] s1, T[] s2) { return (s1.length + s2.length == 0) || (s1.length == s2.length indexOf(s1 ~ s1, s2) != -1); } unittest { // of isRotated assert(isRotated(, )); assert(!isRotated(, x)); assert(!isRotated(x, )); assert(isRotated(x, x)); string s = rotato; assert(isRotated(s, rotato)); assert(isRotated(s, otator)); assert(isRotated(s, tatoro)); assert(isRotated(s, atorot)); assert(isRotated(s, torota)); assert(isRotated(s, orotat)); assert(!isRotated(s, rotator)); assert(!isRotated(s, rotat)); assert(!isRotated(s, rotata)); } void main() {} Bye, bearophile This is what I wrote: bool isRotated(T)(T[] a, T[] b) { return a.length == b.length (a.length == 0 || canFind(chain(a,a), b)); } Use chain to avoid allocation. canFind isn't really the best possible name, is it? Sweet! Thats what I was looking for!
Re: SO rotate question
simendsjo: I agree that's much simpler, but s1 ~ s1 doesn't perform too well I think. Always creates a new heap allocation and copies the array.. The version written by Pelle is better. On the other hand performance is not an absolute thing, it's good enough or not good enough, and in many situations you don't need a high-performance rotate test function. Bye, bearophile
Re: SO rotate question
On 09/03/2010 01:35 PM, bearophile wrote: Pelle: bool isRotated(T)(T[] a, T[] b) { return a.length == b.length (a.length == 0 || canFind(chain(a,a), b)); } Nice clean solution. I suggest to add pure and two const in the signature. canFind isn't really the best possible name, is it? Some name/APIs of Phobos are not the best possible, they were often invented by a single person. I don't know if contains() or isIn() are better. Bye, bearophile Heh, I actually tried that before posting, but chain doesn't seem to support const. :-) Should probably be two forward ranges, not two arrays, as well.
Re: SO rotate question
Pelle: bool isRotated(T)(T[] a, T[] b) { return a.length == b.length (a.length == 0 || canFind(chain(a,a), b)); } Nice clean solution. I suggest to add pure and two const in the signature. canFind isn't really the best possible name, is it? Some name/APIs of Phobos are not the best possible, they were often invented by a single person. I don't know if contains() or isIn() are better. Bye, bearophile
Re: SO rotate question
On Friday 03 September 2010 04:35:30 bearophile wrote: canFind isn't really the best possible name, is it? Some name/APIs of Phobos are not the best possible, they were often invented by a single person. I don't know if contains() or isIn() are better. It used to be that all you had was find(), and you had to check whether the result was empty if you were looking to see whether what you were trying to find was in the range or not. I pointed out that that was overly verbose and less efficient in cases where all you cared about was whether the item or items was in the range rather than getting the range starting at the point where the item was found. I probably suggested contains() for the new function name, but I'd have go look at the bug report. In either case, Andrei agreed that it was a good idea and added the function. However, he named it canFind() - presumably because that's what you're trying to do. You're seeing whether you could find it with find(). So, from that perspective, it's a perfect name. However, I don't think that's really how people think about it. They're looking for whether an element is in a range, not whether they can find it there. So, from that perspective, it's a poor name. Personally, I think that contains() would be better, but canFind() does make sense depending on how you look at it. Now, canFind() might be going away. I opened a bug report asking for all() and any() (all() returning whether all of the elements of a range satisfied a predicate, and and any() returning whether any of them did) and pointed out that while there is no function in std.algorithm which does all(), the version of canFind() which takes a predicate and a haystack but no needle is effectively any(). Andrei thought that any() was better and decided that canFind() should be replaced with any(). After that, I pointed out that while any() is definitely better for the case where it's a just a predicate and a haystack, the other cases would still make more sense as canFind(), and he didn't say anything further on that bug report, so I don't know what he intends to do, and canFind() may or may not be going away. Regardless, contains() is definitely a better name for the other versions of canFind(), so perhaps a bug report should be opened on the matter. Still, naming functions is a bit of an art and most function names are debatable as to how good they are, so you're bound to have functions in any API that aren't named the way that you think they should be. - Jonathan M Davis
Understanding isInfinite(Range)
I was reading about the various range templates in std.range and I found this: http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite Seems simple enough. But I dont understand it's implementation, this from range.d: template isInfinite(Range) { static if (isInputRange!Range is(char[1 + Range.empty])) enum bool isInfinite = !Range.empty; else enum bool isInfinite = false; } What does char[1 + Range.empty] do? It looks rather cryptic..
Re: Understanding isInfinite(Range)
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic andrej.mitrov...@test.com wrote: I was reading about the various range templates in std.range and I found this: http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite Seems simple enough. But I dont understand it's implementation, this from range.d: template isInfinite(Range) { static if (isInputRange!Range is(char[1 + Range.empty])) enum bool isInfinite = !Range.empty; else enum bool isInfinite = false; } What does char[1 + Range.empty] do? It looks rather cryptic.. char[1+Range.empty] is a type. If Range.empty is a compile-time constant, then this type is valid, otherwise it's not valid (the is expression results to true if the argument is a valid type). If it's valid, then Range.empty never changes. If it never changes and it's always false, then it's infinite. -Steve
Re: Understanding isInfinite(Range)
Ah, you're right. Whenever I see the square brackets my brain automatically things we're indexing something. I'll blame that on C. :p Thanks. Steven Schveighoffer Wrote: On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic andrej.mitrov...@test.com wrote: I was reading about the various range templates in std.range and I found this: http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite Seems simple enough. But I dont understand it's implementation, this from range.d: template isInfinite(Range) { static if (isInputRange!Range is(char[1 + Range.empty])) enum bool isInfinite = !Range.empty; else enum bool isInfinite = false; } What does char[1 + Range.empty] do? It looks rather cryptic.. char[1+Range.empty] is a type. If Range.empty is a compile-time constant, then this type is valid, otherwise it's not valid (the is expression results to true if the argument is a valid type). If it's valid, then Range.empty never changes. If it never changes and it's always false, then it's infinite. -Steve
How to name things [Was: Re: SO rotate question]
Jonathan M Davis: Still, naming functions is a bit of an art and most function names are debatable as to how good they are, so you're bound to have functions in any API that aren't named the way that you think they should be. I don't like what you say. If you take a look at how in the last ten years every small feature was designed by Python devs, you see how much care they have for naming things. For each name of feature/built-in all people of the development mailing list propose their names and the rationale behind those names. Then they write down a list of all the ideas, and they vote for each name. The name with most votes usually gets accepted, and then they start over with the next name to choose. This is a bit time consuming, but one of the most important qualities of Python its refined and natural design. You are right that good names are purpose-specific, and often a name that is good for me is not good for you. Every single person has some quirks, so if you let a single person choose a name, there's some risk the name will reflect only the specific quirks of that person. On the other hand the good names for a specific feature are not totally random. If you take 100 smart persons, and you ask them what name to use to define a certain feature, you will often receive something like 15-20 answers, and among them one or two answers are the most common. The most common choice is the the right name choice. It's true that this most common name is not always the same name that each person is willing to chose, but such average process smooths out the quirks each single person has, and very often the names chosen by this process are simple to remember and natural. This is how I'd like Phobos names to be chosen. Andrei is smart and intelligent, but as everyone else he has quirks (and his usage of English is not the most common you may find), so letting the choice of many names to any single person is bad. - I have also added this one: http://d.puremagic.com/issues/show_bug.cgi?id=4803 Bye, bearophile
Re: Threading errors.
So what's the word on this? Will we have simple indexing of tuples via T[] or do we still need T.field[] and T._1 ? The situations is the same in 2.048 as it was in 2.047. There are more examples of tuples being used via T[] in some Phobos code examples (which don't compile and I've reported that). Otherwise if it stays the way it is I'll send Andrei a message to add the corrections to the errata. Philippe Sigaud Wrote: On Tue, Jul 27, 2010 at 19:03, Sean Kelly s...@invisibleduck.org wrote: The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time. Do you mean, indexing tuples directly by a CT value as in msg[1]? Because that was the only error here, I think. div class=gmail_quoteOn Tue, Jul 27, 2010 at 19:03, Sean Kelly span dir=ltrlt;a href=mailto:s...@invisibleduck.org;s...@invisibleduck.org/agt;/span wrote:brblockquote class=gmail_quote style=margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex; The next release, 2.048, should bring things in line with TDPL. I had meant to do this for 2.047, but was too busy with other work to finish in time.br /blockquote/divbrdivDo you mean, indexing tuples directly by a CT value as in msg[1]? Because that was the only error here, I think./divdivbr/div
ubyte[] - immutable(ubyte)[]
This is from TDPL page 407: import std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 1024 * 100; auto tid = spawn(fileWriter); // Read loop foreach (immutable(ubyte)[] buffer; stdin.byChunk(bufferSize)) { send(tid, buffer); } } void fileWriter() { // write loop while (true) { auto buffer = receiveOnly!(immutable(ubyte)[])(); tgt.write(buffer); } } Error: C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1943): Error: cannot implicitly convert expression (buffer) of type ubyte[] to immutable(ubyte)[] Yet interestingly I can't use type inference: foreach (buffer; stdin.byChunk(bufferSize)) { send(tid, buffer); } Error: stdin_stdout_copy.d(11): Error: cannot infer type for buffer But in the original code I get back a mutable ubyte[] which I can't implicitly convert to immutable (I'd need a copy first). There's no .dup or .idup property for stdin.byChunk. So what am I supossed to do here?
Re: How to name things [Was: Re: SO rotate question]
On Friday 03 September 2010 10:14:24 bearophile wrote: Jonathan M Davis: Still, naming functions is a bit of an art and most function names are debatable as to how good they are, so you're bound to have functions in any API that aren't named the way that you think they should be. I don't like what you say. If you take a look at how in the last ten years every small feature was designed by Python devs, you see how much care they have for naming things. For each name of feature/built-in all people of the development mailing list propose their names and the rationale behind those names. Then they write down a list of all the ideas, and they vote for each name. The name with most votes usually gets accepted, and then they start over with the next name to choose. This is a bit time consuming, but one of the most important qualities of Python its refined and natural design. You are right that good names are purpose-specific, and often a name that is good for me is not good for you. Every single person has some quirks, so if you let a single person choose a name, there's some risk the name will reflect only the specific quirks of that person. On the other hand the good names for a specific feature are not totally random. If you take 100 smart persons, and you ask them what name to use to define a certain feature, you will often receive something like 15-20 answers, and among them one or two answers are the most common. The most common choice is the the right name choice. It's true that this most common name is not always the same name that each person is willing to chose, but such average process smooths out the quirks each single person has, and very often the names chosen by this process are simple to remember and natural. This is how I'd like Phobos names to be chosen. Andrei is smart and intelligent, but as everyone else he has quirks (and his usage of English is not the most common you may find), so letting the choice of many names to any single person is bad. I didn't say anything that contradicts what you just said. All I said was that picking a function name is an art, and there _are_ going to be function names in an API that people aren't going to like simply because they think differently. Heck, you could really like one of your own names when you first create the function, and then later decide that it was a poor choice. What you're proposing is a way to reduce the odds that the average programmer will think that a name is bad, because more people will have input. I have no problem with that, and I didn't suggest that the way that names in Phobos is picked is perfect. I didn't even say anything about whether having one person pick the names was good or bad. So, I really don't know why you're unhappy with what I said. In any case, it looks like Andrei is looking to have more of a review process for stuff entering Phobos - akin to what Boost does. That review process would likely be the time to suggest better names for functions if they are poorly named. - Jonathan M Davis
RosettaCode: Echo Server
Hello, I decided to exercise my skills in D a bit and wrote an implementation for an echo server using D. I figure before I post it to the site, I'd post it here for comments as I'd like to get the best possible version on the site vs. something that's half-assed. Considering I'm very new to socket programming, I'm guessing this may not be the best possible version. Attached are two files: a client and a server. Let me know what you think. Casey import std.socket; import std.stdio; import std.string; void main() { Socket sock = new TcpSocket(new InternetAddress(localhost, 12321)); string[4] messages = [Hello world., Hello\nworld., \tHello world., Goodby cruel world...]; ubyte buff[1]; int bytesRead; foreach (msg; messages) { sock.send(msg); for (int i = 0; i msg.length; i++) { bytesRead = sock.receive(buff); write(cast(char)buff[0]); } /* string temp = cast(string)buff; writeln(temp, \n); */ write(\n); } sock.close(); } import std.socket; import std.array; void main() { Socket listener = new TcpSocket; assert(listener.isAlive); listener.bind(new InternetAddress(12321)); listener.listen(10); Socket currSock; uint bytesRead; ubyte buff[1]; while(1) { currSock = listener.accept(); while ((bytesRead = currSock.receive(buff)) 0) { currSock.send(buff); } currSock.close(); buff.clear(); } }
About std.stdio.File.writef
With dmd 2.048 this code: import std.stdio: File; void main() { auto f = File(TEST.ppm, w); f.writef(%c, 50); } Prints at run-time: std.format.FormatError: std.format integral So to write a char I've had to use: f.write(cast(char)50); Partially unrelated: is is possible to perform something like f.readfln()? Do I have to use std.conv.parse for it? Bye and thank you, bearophile
[Issue 4672] [patch] rdmd fails when -I is needed
http://d.puremagic.com/issues/show_bug.cgi?id=4672 --- Comment #4 from Nick Sabalausky cbkbbej...@mailinator.com 2010-09-03 00:05:07 PDT --- There's a typo in the test case above: - $ cat src/app/main.d module app.main; import foo; void main(){} - Should be: - $ cat src/app/main.d module app.main; import lib.foo; void main(){} - (ie, Line 2 of src/app/main.d) With that change, the test case fails with rdmd r1400, but works with xfbuild and with the rdmd patch above. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
access member error
I've got 2 classes: class A { private int _x = 5; } class B : A { void output() { writeln(_x); } } When I call (new B).output() there is no compile-time or run-time errors. Is it correct?
[Issue 3418] link error with cast(ulong)(ulong*real)
http://d.puremagic.com/issues/show_bug.cgi?id=3418 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||FIXED --- Comment #3 from Walter Bright bugzi...@digitalmars.com 2010-09-03 01:35:02 PDT --- http://www.dsource.org/projects/druntime/changeset/379 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4173] Regression(2.037) Explicitly instantiated templates still try to do IFTI in some cases
http://d.puremagic.com/issues/show_bug.cgi?id=4173 --- Comment #3 from Don clugd...@yahoo.com.au 2010-09-03 01:45:03 PDT --- It seems to be just luck that this ever worked at all. Template parameter deduction has never worked for base classes or interfaces of a class. So although this particular case used to work, it was very fragile -- very closely related cases would fail. I've only been able to fix this by implementing template parameter deduction for base classes. It allows them as a match with implicit conversion. Thus, it also fixes bug 1715 Template specialization checks for equality rather than convertibility and bug 1970 Templated interfaces not matched. But I've found a very annoying case: interface I(X) {} class C: I!(char), I!(double) {} void foo(T)(I!(T) x) {} void main() { C c = new C; foo(c); // could match with I!char or I!double } This should be treated as a match-with-implicit-conversion for c, but the type T has not been determined, so template instantiation should fail. If the signature is instead: foo(T)(I!(T) x, T y){} and called with foo(c, 1.2), then instantiation should succeed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
Re: access member error
On Friday 03 September 2010 00:36:11 existen wrote: I've got 2 classes: class A { private int _x = 5; } class B : A { void output() { writeln(_x); } } When I call (new B).output() there is no compile-time or run-time errors. Is it correct? This is the wrong list to send posts to. All of the posts here come from the bug tracker. Use digitalmars-d-learn for questions about how D works or how to do things in D. As for your code, it looks just fine to me assuming that A and B are in the same module. private is private to the module, not the class. If A and B are in separate modules, then B would not have access to _x, and it wouldn't work. For that to work, you'd need to make _x protected. But if they're in the same module, then it should work just fine. - Jonathan M Davis
[Issue 4792] New: Assertion in shift right operations.
http://d.puremagic.com/issues/show_bug.cgi?id=4792 Summary: Assertion in shift right operations. Product: D Version: D1 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: ibuc...@ubuntu.com --- Comment #0 from Iain Buclaw ibuc...@ubuntu.com 2010-09-03 02:19:14 PDT --- Both examples: int main() { return cast(int)(.00); } int main() { return cast(int)(.00); } result in an ICE in the compiler. Whereas int main() { return cast(int)(.00); } is handled perfectly fine. As this is not supposed to be compilable, I assume that the error type isn't being handled as it should be. Regards -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4794] New: Stack overflow on recursive auto assignments
http://d.puremagic.com/issues/show_bug.cgi?id=4794 Summary: Stack overflow on recursive auto assignments Product: D Version: D1 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: ibuc...@ubuntu.com --- Comment #0 from Iain Buclaw ibuc...@ubuntu.com 2010-09-03 02:40:46 PDT --- Simplest case to reproduce. auto a = a; ICEs the compiler, a backtrace reveals an infinite recursion causes it... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4795] New: new demangler + dmd test suite -- a problem
http://d.puremagic.com/issues/show_bug.cgi?id=4795 Summary: new demangler + dmd test suite -- a problem Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: s...@invisibleduck.org ReportedBy: bra...@puremagic.com --- Comment #0 from Brad Roberts bra...@puremagic.com 2010-09-03 02:54:09 PDT --- One of the tests in the dmd test suite is having an issue with the new demangle code in druntime. To reproduce, from the dmd test directory: make test_results/runnable/eh.d.out The stack trace via gdb: #0 rt.dmain2._d_setunhandled (o=0x806b898) at src/rt/arrayshort.d:64 #1 0x0805d14b in rt.deh2._d_throw (h=0x806b898) at src/rt/deh2.d:103 #2 0x0806611e in core.demangle.demangle.error (msg=578358990409302030) at src/core/cpuid.d:569 #3 0x08068c01 in core.demangle.demangle.parseSymbolName (this=0xb038) at src/core/demangle.d:1188 #4 0x08068c3e in core.demangle.demangle.parseQualifiedName (this=0x806311a) at src/core/demangle.d:1208 #5 0x0806600b in core.demangle.demangle (dst=0, buf=578671844417077272) at src/core/demangle.d:1226 #6 0x080638a5 in core.runtime.defaultTraceHandler.DefaultTraceInfo.opApply (this=0x2e0fc0, dg=578088651209044196) at src/core/cpuid.d:428 #7 0x0805c851 in object.Throwable.toString (this=0x2e1fc0) at src/object_.d:1170 #8 0x0805a8ec in eh.test4 () at runnable/eh.d:164 #9 0x0805ae63 in D main () at runnable/eh.d:351 #10 0x0805d5b6 in rt.dmain2.main.runMain (this=0xb258) at src/rt/arrayint.d:198 #11 0x0805d510 in rt.dmain2.main.tryExec (this=0xb258, dg=578102996399813208) at src/rt/arrayfloat.d:240 #12 0x0805d5fa in rt.dmain2.main.runAll (this=0x0) at src/core/thread.d:411 #13 0x0805d510 in rt.dmain2.main.tryExec (this=0xb258, dg=578103185378374232) at src/rt/arrayfloat.d:240 #14 0x0805d4b6 in rt.dmain2.main (argc=1, argv=0x1f6770) at src/rt/arrayint.d:111 (gdb) up The string in question, if gdb isn't lying to me: _Dmain+0x27) [0x805ae63] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4795] new demangler + dmd test suite -- a problem
http://d.puremagic.com/issues/show_bug.cgi?id=4795 Brad Roberts bra...@puremagic.com changed: What|Removed |Added Severity|normal |regression -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4796] New: std.array.appender changes broke dmd unit test runnable/untag.d
http://d.puremagic.com/issues/show_bug.cgi?id=4796 Summary: std.array.appender changes broke dmd unit test runnable/untag.d Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: regression Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: bra...@puremagic.com --- Comment #0 from Brad Roberts bra...@puremagic.com 2010-09-03 03:04:22 PDT --- To reproduce, from the dmd test dir: make test_results/runnable/untag.d.out The errors: runnable/untag.d(105): Error: template std.array.appender(A : E[],E) does not match any function template declaration runnable/untag.d(105): Error: template std.array.appender(A : E[],E) cannot deduce template function from argument types !()(string*) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4797] New: onOutOfMemoryError in dmd unit test causes segv
http://d.puremagic.com/issues/show_bug.cgi?id=4797 Summary: onOutOfMemoryError in dmd unit test causes segv Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: s...@invisibleduck.org ReportedBy: bra...@puremagic.com --- Comment #0 from Brad Roberts bra...@puremagic.com 2010-09-03 03:09:09 PDT --- to reproduce, from the dmd test directory: make test_results/runnable/testdstress.d.out gdb stacktrace: (gdb) bt #0 rt.dmain2._d_setunhandled (o=0x80a3aec) at src/rt/arrayshort.d:64 #1 0x080878cb in rt.deh2._d_throw (h=0x80a3aec) at src/rt/deh2.d:103 #2 0x0808702e in core.exception.onOutOfMemoryError () at src/core/demangle.d:57 #3 0x08081baa in dstress.run.module_01.test35 () at runnable/testdstress.d:710 #4 0x08081fa6 in D main () at runnable/testdstress.d:903 #5 0x08087d56 in rt.dmain2.main.runMain (this=0xb248) at src/rt/arrayint.d:198 #6 0x08087cb0 in rt.dmain2.main.tryExec (this=0xb248, dg=578850251989840456) at src/rt/arrayfloat.d:240 #7 0x08087d9a in rt.dmain2.main.runAll (this=0x80bc390) at src/core/thread.d:411 #8 0x08087cb0 in rt.dmain2.main.tryExec (this=0xb248, dg=578850440968401480) at src/rt/arrayfloat.d:240 #9 0x08087c56 in rt.dmain2.main (argc=1, argv=0x1f6770) at src/rt/arrayint.d:111 The file/lineno look rather suspect, but the function names look fairly sane. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---