embd 0.1.0 - embedded D
Announcing the release of embd, a low-level (i.e. small) API for embedding D code into text: https://github.com/carlor/embd It's a bit of an inconvenient API, but it's customizable and gives the client control in what gets passed to the template. I hope some of you find it useful! NMS
Re: embd 0.1.0 - embedded D
On Wednesday, 6 March 2013 at 11:29:51 UTC, Sönke Ludwig wrote: Am 06.03.2013 10:08, schrieb Nathan M. Swan: Announcing the release of embd, a low-level (i.e. small) API for embedding D code into text: https://github.com/carlor/embd It's a bit of an inconvenient API, but it's customizable and gives the client control in what gets passed to the template. I hope some of you find it useful! NMS Great, finally something that works for plain text files! I guess a simple wrapper could make it work with a similar interface to vibe.d's Diet templates (slightly ugly with that struct because of the additional range template argument and not tested at all): struct renderEmbd(string FILE, ALIASES...) { class Context(R) : emdb.Context { R* _output; mixin(renderer); void write(string content, dchar evalCode){ if (evalCode == '=') filterHtmlEscape(*_output, content); else _output.put(content); } } static void opCall(R)(ref R output_range) { static Context!R ctx; if( !ctx ) ctx = new Context!R; ctx._output = output_range; scope(exit) ctx._output = null; ctx.render!(import(FILE), `!=`, `%`, `%`)(); } } Usage: auto dst = appender!string(); renderEmbd!(userprofile.embd.html, username, title, biography)(dst); Yes, my original intent was to use it in vibe.d projects. Should I try to adopt it into vibe.d? NMS
Re: vibe.d 0.7.12 released
On Monday, 11 February 2013 at 21:41:33 UTC, Jacob Carlborg wrote: On 2013-02-11 22:07, FG wrote: The problem I have with those is that they are designed for HTML. What if I wanted to make an email template instead? Erb is like a Ruby preprocessor that can be used for any format. It's used for many things in Ruby on Rails: index.html.erb - Erb preprocessor, result is HTML % if foo % liasd/li % end % bar.js.coffee.erb - Erb then CoffeeScript preprocessor, result is JavaScript % if foo % bar = - console.log(asd) % end % foo.text.erb - Erb preprocessor, result is plain text % if foo % asd % end % database.yml.erb - Erb preprocessor, result is YAML development: username: %= username % password: %= password % This really makes sense for D. It can be easily combined with D's mixin capabilities to make it so you don't even need to implement stuff like various loops: % [d code] % - [d code] %= [d expr] % - buffer.write([d expr]); [text]- buffer.write([text]); NMS
Re: GC vs. Manual Memory Management Real World Comparison
On Wednesday, 5 September 2012 at 11:03:03 UTC, Benjamin Thaut wrote: I rewrote a 3d game I created during my studies with D 2.0 to manual memory mangement. If I'm not studying I'm working in the 3d Engine deparement of Havok. As I needed to pratice manual memory management and did want to get rid of the GC in D for quite some time, I did go through all this effort to create a GC free version of my game. The results are: DMD GC Version: 71 FPS, 14.0 ms frametime GDC GC Version: 128.6 FPS, 7.72 ms frametime DMD MMM Version: 142.8 FPS, 7.02 ms frametime GC collection times: DMD GC Version: 8.9 ms GDC GC Version: 4.1 ms As you see the manual managed version is twice as fast as the garbage collected one. Even the highly optimized version created with GDC is still slower the the manual memory management. You can find the full article at: http://3d.benjamin-thaut.de/?p=20#more-20 Feedback is welcome. Kind Regards Benjamin Thaut Did you try GC.disable/enable?
Re: The best programming advice I ever got
On Wednesday, 29 August 2012 at 14:53:39 UTC, Andrei Alexandrescu wrote: Not directly related to D, but hopefully a hook :o). http://www.informit.com/articles/article.aspx?p=1945828 Andrei Great article. Learning to learn is really what distinguishes vocational training from true education. NMS
Re: XSort - Sorting algorithms (including Timsort!)
On Thursday, 12 April 2012 at 03:04:49 UTC, Xinok wrote: I just wanted to share this. I started a project a few weeks ago on Github to implement several sorting algorithms in D. In total, there are 8 modules at the moment, each implementing a sorting algorithm or combination thereof. https://github.com/Xinok/XSort I just finished Timsort today. It's working, it's stable, but I need to spend a little more time better optimizing it. Cool! To make it a bit more generic, may I suggest making all the inputs only have to be isInputRange, and have it converted to an array. NMS
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 The primitives/utility distinction is an idea I've thought about a lot. UFCS is justifiable not only as a syntactic convenience but as a solution to an important design principle. Great work guys! NMS
Re: dcaflib
On Monday, 26 March 2012 at 13:56:46 UTC, Dejan Lekic wrote: Nathan, what terminals are supported? Only ANSI / VT* or some other types of terminals as well? I've only tested it on OSX Terminal, but I read about the features on a Linux website, and have used the ANSI escape code Wikipedia article as reference, so I assume it's ANSI. NMS
dcaflib
In a post from a few weeks ago, someone mentioned terminal colors. Currently, I have one that works with bash (cmd pending) at https://github.com/carlor/dcaflib. Example code: import dcaflib.ui.terminal; import std.stdio; void main() { fgColor = TermColor.RED; writeln(this is red!); fgColor = TermColor.BLUE; writeln(this is blue!); }