Re: Thrift now officially supports D!
Nice, anyone made a D hadoop app? On Wed, Mar 28, 2012 at 1:16 AM, David Nadlinger s...@klickverbot.at wrote: Apache Thrift is a cross-language serialization/RPC framework. During last year's Google Summer of Code, I worked on adding D as a target language – and a few days ago, the D implementation has been accepted into the upstream project! You can find a short overview of the capabilities of the library and the obligatory collection of source/doc links at my blog: http://klickverbot.at/blog/2012/03/thrift-now-officially-supports-d/ David
Re: Pegged: Syntax Highlighting
On 3/27/12, Philippe Sigaud philippe.sig...@gmail.com wrote: Nice one. Care to explain how you did it? Sure. Currently the editor is just a viewer (can't edit text ironically :p), and is a port of one of the lessons of Neatpad (http://www.catch22.net/tuts/neatpad). It's win32-specific and later lessons cover very platform-specific unicode stuff so I haven't really bothered with the rest of the tutorial. What I have is one large char[]/wchar[] buffer, I store indices to newlines within this buffer and when I need to lex a certain line I just pass a slice into DDMD's lexer based on the position of the newlines. I then store the beginning of each token and its type (e.g. { index 5, TOK.TOKImport }) as an array for that specific line. It's easy to paint a line this way. But I do have a couple of issues. One is that I have no way to figure out where empty spaces are and not just spaces within string literals. The DDMD API only exposes the beginning of each token and not its length. And the lexer doesn't tokenize empty spaces between real tokens. So with a string like this: import foo; The space between 'import' and 'foo' ends up being treated as 'TOK.TOKImport'. It's not a big issue when I only have foreground coloring (empty space won't be drawn), but when I have background coloring I end up with this: http://i.imgur.com/0wUcR.png The other issue is that DDMD explicitly takes a char[] and not just any input range. The WinAPI text-drawing APIs require UTF16 arrays (the unicode-aware functions anyway), so I end up having to store two buffers, one UTF8 and one UTF16. I'm sure these issues can be fixed in DDMD though. With that being said the paint routine only takes about ~150 microseconds to finish which is pretty neat. Anyway if you have a win32 box you can clone: https://github.com/AndrejMitrovic/DNeatpad Then run: DNeatpad\WindowsAPI\build.bat DNeatpad\ddmd\build.bat DNeatpad\textview\build.bat That last one builds the neatpad folder as well. Anyway I was just doing this for fun I have no intention on writing text editors. :)
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: snip Btw it crashes sometime when I open std.datetime and scroll and resize the window. I've no idea what's causing it. I don't seem to index pass array bounds, and I'm not allocating win32 handles all the time either. A catch(Throwable) doesn't help. Oh well..
Re: Thrift now officially supports D!
This is cool...anyone got an example using Thrift (in D) over ZeroMQ (with D bindings)...I've been using that in c# and this works very well... ~ filgood On 28/03/2012 08:36, Rory McGuire wrote: Nice, anyone made a D hadoop app? On Wed, Mar 28, 2012 at 1:16 AM, David Nadlingers...@klickverbot.at wrote: Apache Thrift is a cross-language serialization/RPC framework. During last year's Google Summer of Code, I worked on adding D as a target language – and a few days ago, the D implementation has been accepted into the upstream project! You can find a short overview of the capabilities of the library and the obligatory collection of source/doc links at my blog: http://klickverbot.at/blog/2012/03/thrift-now-officially-supports-d/ David
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: snip Accidentally left out ddmd from the repo but now it's in. I think it should compile now. Let me know if it doesn't.
Re: D Conference 2012
On 28/03/2012 02:30, Bernard Helyer wrote: On Tuesday, 27 March 2012 at 21:29:08 UTC, Walter Bright wrote: The web site is up now: http://www.astoriaseminar.com See you all there! Someday, when I'm rich and famous, I'll be able to afford to travel to such things. For now, I must play the flightless kiwi and request lots of pictures and videos! I second this request! -- Robert http://octarineparrot.com/
Re: Thrift now officially supports D!
On Wednesday, 28 March 2012 at 08:16:55 UTC, filgood wrote: This is cool...anyone got an example using Thrift (in D) over ZeroMQ (with D bindings)...I've been using that in c# and this works very well... I haven't personally used Thrift in conjunction with ZeroMQ, but a 0mq transport should be just as easy to implement as with C++/C#. David
Why D needs tail const
With arrays and pointers, you can declare const(int[]) constData; immutable(int[]) immutableData; to enforce constancy constraints. The type modifiers apply both to the reference to the data and to the data being referenced. If you want to be able to change what data the variables reference, just not change the data itself, no problem: const(int)[] constData; immutable(int)[] immutableData; However, this can't be done with classes. You can't do it with language builtins, anyway. Rather, a class object reference is either mutable, const or immutable, and this simultaneously affects both the reference itself and the referenced object. This is unideal. Whether a reference to an object can change what it refers to and whether the object itself can change are two distinct concepts. OK, so we have std.typecons.Rebindable. But I've found it a PITA when it comes to generic programming. Among other things, if you try to pass it around, you can end up with a mess like const(Rebindable!(const())). This wouldn't happen with built-in tail const support. I guess that, at the code level, tailConst and tailImmutable would be just type modifiers. But at the semantic level, they're just the const and immutable modifiers we already have being applied at a different level. So: - tailConst(int[]) would be equivalent to const(int)[] - tailConst(Class) would be a whole new type modification, under which the reference can be reassigned, but the object's state cannot be changed through this reference, and when calling methods of it the this pointer is const. - const(tailConst(anything)) would just be the same as const(anything) - tailConst(Struct) would just collapse to Struct if the struct contains no references or only const and/or immutable references. Otherwise, it would be a distinct type modifier that forces all references within the struct to be const. (Should we allow struct methods to be qualified as tailConst/tailImmutable?) - tailImmutable would work in the same way. - You could have more involved constructs like const(tailImmutable(Class))[]. This would be an array of constant references to immutable objects. So through this array reference, neither what objects are in the array nor the objects themselves can be changed. But there may also exist a tailImmutable(Class)[] referencing the same block of memory, through which what objects are in the array can be changed, but the objects themselves remain immutable. So essentially, where the columns denote top-level constancy and the rows the next level down: | mutable const immutable --+- mutable | no mod const | tailConst const immutable | tailImmutable const(tailImmutable) immutable Moreover, who thinks it would be nice if immutable classes could behave just like primitives? Java gets partway there with String and others - you can just declare a String variable and assign to it as you would an integer, and be confident that some outside process won't change the contents of the variable behind your back. D could be there with such improvements as built-in tail immutable (and making it the default modifier when a variable of an immutable class is declared). What do people think to the whole idea? Stewart.
Re: Why D needs tail const
I'm pretty sure there's a dmd pull request or patch or something for this already. IIRC Michel Fortin implemented it as Object ref obj; (which is the same as Object obj;) and const(Object) ref obj; as tail const. Don't know where it is now though...
Re: Why D needs tail const
On Wednesday, 28 March 2012 at 14:11:10 UTC, Adam D. Ruppe wrote: I'm pretty sure there's a dmd pull request or patch or something for this already. IIRC Michel Fortin implemented it as Object ref obj; (which is the same as Object obj;) and const(Object) ref obj; as tail const. Don't know where it is now though... One of the first pull requests https://github.com/D-Programming-Language/dmd/pull/3
Re: Why D needs tail const
Stewart Gordon: OK, so we have std.typecons.Rebindable. But I've found it a PITA when it comes to generic programming. Among other things, if you try to pass it around, you can end up with a mess like const(Rebindable!(const())). This wouldn't happen with built-in tail const support. This is only partially related to your post. It's for a general solution. Is it possible to invent a language construct that allows: const(Rebindable!(const())) To be defined as the same as: Rebindable!(const()) Something like an onConst()/onImmutable templated methods for structs/classes? Bye, bearophile
Re: Thrift now officially supports D!
On Tuesday, 27 March 2012 at 23:16:29 UTC, David Nadlinger wrote: Apache Thrift is a cross-language serialization/RPC framework. During last year's Google Summer of Code, I worked on adding D as a target language – and a few days ago, the D implementation has been accepted into the upstream project! You can find a short overview of the capabilities of the library and the obligatory collection of source/doc links at my blog: http://klickverbot.at/blog/2012/03/thrift-now-officially-supports-d/ David http://www.reddit.com/r/programming/comments/rhk6m/thrift_now_officially_supports_d_d_programming/
Re: Why D needs tail const
Stewart Gordon, el 28 de marzo a las 14:54 me escribiste: What do people think to the whole idea? I think this is not an announcement at all and shouldn't be discussed in this list :) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ -- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) -- Soy como una mosca, parada en el agua. Y vos sos un transatlántico, querés nadar a mi lado. Y me estás ahogando.
Re: Why D needs tail const
I'm not sure how my post ended up in .announce, but anyway On 28/03/2012 15:24, bearophile wrote: snip Is it possible to invent a language construct that allows: const(Rebindable!(const())) To be defined as the same as: Rebindable!(const()) You mean be defined the same as const(...) ? It's the only thing that makes sense. Something like an onConst()/onImmutable templated methods for structs/classes? Maybe something like struct Rebindable(T) { alias const(T) onConst; } which would make const(Rebindable!(T)) just const(T)? I'm not sure whether this would be a good idea. And it would solve only one of Rebindable's many shortcomings Stewart.
Re: Why D needs tail const
On 28/03/2012 16:09, Stewart Gordon wrote: snip Something like an onConst()/onImmutable templated methods for structs/classes? snip I'm not sure whether this would be a good idea. And it would solve only one of Rebindable's many shortcomings Moreover, any feature that makes a type a completely different type if constancy is applied to it could be abused in all kinds of ways, as well as breaking generic programming. And I can't see any other genuine use case it might have. On this basis, we might as well just implement built-in tail const instead. Stewart.
Re: Pegged: Syntax Highlighting
On 3/27/12, Philippe Sigaud philippe.sig...@gmail.com wrote: snip Philippe your example on this wiki page doesn't seem to work: https://github.com/PhilippeSigaud/Pegged/wiki/ import pegged.grammar; mixin(grammar( Expr - Factor AddExpr* AddExpr - ('+'/'-') Factor Factor - Primary MulExpr* MulExpr - ('*'/'/') Primary Primary - Parens / Number / Variable / '-' Primary Parens - '(' Expr ')' Number ~ [0-9]+ Variable - Identifier)); void main() { auto parseTree2 = Expr.parse( 0 + 123 - 456 ); writeln(parseTree2.capture); } [Expr failure at pos [index: 0, line: 0, col: 0], Factor failure at pos [index: 0, line: 0, col: 0], Primary failure at pos [index: 0, line: 0, col: 0], Parens failure at pos [index: 0, line: 0, col: 0], Lit!(() failure at pos [index: 0, line: 0, col: 0]]
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/27/12, Philippe Sigaud philippe.sig...@gmail.com wrote: snip Philippe your example on this wiki page doesn't seem to work: https://github.com/PhilippeSigaud/Pegged/wiki/ Actually it seems to work if I remove all the spaces from the input string. Maybe the grammar is just missing another rule that allows spaces?
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/27/12, Philippe Sigaud philippe.sig...@gmail.com wrote: snip Philippe your example on this wiki page doesn't seem to work: https://github.com/PhilippeSigaud/Pegged/wiki/ Actually it seems to work if I remove all the spaces from the input string. Maybe the grammar is just missing another rule that allows spaces? Okay I got it, you've recently changed some code. I can see it mentioned in the readme: By default, the grammars do not silently consume spaces, as this is the standard behavior for PEGs. There is an opt-out though, with the simple `` arrow instead of `-` (you can see it in the previous example) So yeah, if I change to '' it works. :)
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: snip Ouch, DMD crashes with that autogenerated ddump D grammar file.
Re: Pegged: Syntax Highlighting
On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: snip Ouch, DMD crashes with that autogenerated ddump D grammar file. Also asModule seems to have stopped generating valid modules since the last time I've tried it. I keep getting this error when importing a generated file: arithmetic.d(44): Error: undefined identifier module arithmetic.empty arithmetic.d(31):called from here: parse(Input(input,Pos(0u,0u,0u),AssociativeList(null))) simpleTest.d(30):called from here: parse(2/(8*7988+1*6196-y)) Failed: dmd -w -wi -v -o- simpleTest.d -I.
Re: Pegged: Syntax Highlighting
On Wed, Mar 28, 2012 at 18:06, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Okay I got it, you've recently changed some code. I can see it mentioned in the readme: By default, the grammars do not silently consume spaces, as this is the standard behavior for PEGs. There is an opt-out though, with the simple `` arrow instead of `-` (you can see it in the previous example) So yeah, if I change to '' it works. :) Damn, I changed README.md a few days ago and forgot the equivalent page in the wiki :( I knew that duplicating content would cause trouble.
Re: Pegged: Syntax Highlighting
On Wed, Mar 28, 2012 at 19:08, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/28/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: snip Ouch, DMD crashes with that autogenerated ddump D grammar file. Yeah, I spent two evenings trying to get why there is a segmentation fault. I found some nice bugs (the rules have an internal member called 'name' and for recursive rules it can become infinite). I still don't get why the D grammar does this. I'll start again, with a C grammar (I read one from the ANSI report today). I should have done it in smaller steps. Right now, I'm more into changing bits of the underlying code and then will code grammars again.
Re: Pegged: Syntax Highlighting
On Wed, Mar 28, 2012 at 19:19, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Also asModule seems to have stopped generating valid modules since the last time I've tried it. I keep getting this error when importing a generated file: arithmetic.d(44): Error: undefined identifier module arithmetic.empty arithmetic.d(31): called from here: parse(Input(input,Pos(0u,0u,0u),AssociativeList(null))) simpleTest.d(30): called from here: parse(2/(8*7988+1*6196-y)) Failed: dmd -w -wi -v -o- simpleTest.d -I. Ah, I'm preparing a future switch to ranges and changed 'arr.length == 0' calls to 'arr.empty'. I forgot to put an 'import std.array;' at the beginning of 'asModule()( I guess. OK, it's done and on Github. Thanks for the headup!
Re: Pegged: Syntax Highlighting
On 3/28/12, Philippe Sigaud philippe.sig...@gmail.com wrote: OK, it's done and on Github. Thanks for the headup! Cool, thanks for the quick fixes! I see that each child in the parse tree has a begin/end position mark, this seems to be exactly what I need for syntax highlighting. I'll try have some fun with it.
Re: Thrift now officially supports D!
On 3/27/2012 4:16 PM, David Nadlinger wrote: Apache Thrift is a cross-language serialization/RPC framework. During last year's Google Summer of Code, I worked on adding D as a target language – and a few days ago, the D implementation has been accepted into the upstream project! You can find a short overview of the capabilities of the library and the obligatory collection of source/doc links at my blog: http://klickverbot.at/blog/2012/03/thrift-now-officially-supports-d/ David This is great news!
UFCS for D
http://www.reddit.com/r/programming/comments/rif9x/uniform_function_call_syntax_for_the_d/ Andrei
Re: UFCS for D
On Thursday, 29 March 2012 at 00:21:38 UTC, Andrei Alexandrescu wrote: http://www.reddit.com/r/programming/comments/rif9x/uniform_function_call_syntax_for_the_d/ Andrei Awesome! Been wanting this ever since I bought TDPL! :D One question though, what takes priority, UFCS or opDispatch?
Re: UFCS for D
On Thursday, 29 March 2012 at 00:21:38 UTC, Andrei Alexandrescu wrote: http://www.reddit.com/r/programming/comments/rif9x/uniform_function_call_syntax_for_the_d/ Andrei I won't be going out of my way to check this, but there is a mention of adding the range primatives. This works, but it doesn't make the class a range for any other module, so std.algorithms won't recogonise it as a range.
Linux and D wallpaper :)
Don't know if this is the place for this sort of announcement Found a great looking Linux logo over at gnome-look.org by kodama (http://gnome-look.org/content/show.php/Linux+Logo?content=142418). So I thought I'd modify it a bit and make some wallpapers. D sounded like a great place to start. Here's the first go (1080p): http://reign-studios.com/d-wallpapers/LinuxAndD.png I'll make a few more and post them here (suggestions welcome). Also, if anyone wants the original Inkscape files just let me know.
Re: Linux and D wallpaper :)
On 29 March 2012 17:48, F i L witte2...@gmail.com wrote: Don't know if this is the place for this sort of announcement Found a great looking Linux logo over at gnome-look.org by kodama (http://gnome-look.org/content/show.php/Linux+Logo?content=142418). So I thought I'd modify it a bit and make some wallpapers. D sounded like a great place to start. Here's the first go (1080p): http://reign-studios.com/d-wallpapers/LinuxAndD.png I'll make a few more and post them here (suggestions welcome). Also, if anyone wants the original Inkscape files just let me know. Looks awesome. Although, while I like the Men are from Mars quote, I can see it being taken the wrong way... -- James Miller
Re: Linux and D wallpaper :)
On Thursday, 29 March 2012 at 04:48:39 UTC, F i L wrote: http://reign-studios.com/d-wallpapers/LinuxAndD.png Very nice. Thanks!!
Re: Linux and D wallpaper :)
James Miller wrote: Although, while I like the Men are from Mars quote, I can see it being taken the wrong way... Ya I was anticipating that. I'll be making a version without any sayings, but I'm still playing around with ways to fill that void a bit.