Does this need to be a class, can it be a struct instead?


Ya know, it might be able to be made into a struct; I'll fiddle with it tomorrow. The main reason it was made a class was so .join had to take a Table type as its first parameter, and internally Table implements a Joinable interface (which is needed for chaining .joins and propagating the table name during printing).

Why is 'new Sql("*")' needed? If you need to have a specific type, could it be a struct instead?

The Sql class is needed because it's a node in the AST (all nodes inherit from a basic Node class) that just prints out its content verbatim when to_sql is called. All the methods that take a Node would need to be modified/templated to also accept a specialized SQL struct type, which unfortunately isn't feasible. If it was done, it'd probably be implemented using std.variant's Algebraic type, but then CTFE is forfeited. If you know of another way to go about doing this, I'd be really interested in hearing it. It is unfortunate that the library has to make so many small allocations, for sure.

Another option is, you could try using CTFE as much as possible to get the allocations over with at compile time :)


The library can be found at: https://github.com/dymk/regal
And the dub package: http://code.dlang.org/packages/regal

This all looks pretty nice :). Does it work at compile time?

Thank you! I haven't tested it, but it's not using any features that would impede CTFE. So that's a solid "probably".

Reply via email to