December 22, 2010Re: New syntax for string mixins
Posted in reply to Don
"Don" <firstname.lastname@example.org> wrote: > It's not that complicated. Once you can load the library and call *one* > function in it, the problem is solved. > But at a deeper level, I'm not sure what you'd hope to achieve with this. > I mean (excluding some not-yet implemented features), CTFE allows you to > execute any pure + safe function which you have source code for. > > So, if you had such a plugin, it could do things like make database queries. Everything else you can do already. May be you are right, I don't know. So yes - adding plugins is questionable feature now. I thought on it in general, and found several things they are suitable for, not sure if so useful: (1) To call external tools, e.g. SQL-syntax validator, DSL code parser ; (2) To load and handle resources at CT, e.g. (*) load XML, JSON, etc. generated by IDE GUI and convert it to D code; (*) load resources as handled data in inner program format, like: auto imgData = mixin (loadJPEG ("./img/photo1.jpeg")) ; (that seems useful) (3) make impure CTFE functions, e.g. one macro configures the state, and some/all other depend on it (like optimisation options, hardware resources, etc.) or cache result from call to call like fibonacci numbers. (4) Workaround CTFE limitations if really needed (questionable, as you pointed above).
Copyright © 1999-2016 by the D Language Foundation