Archive for May 2013

How to simplify memory management the right way

As I pointed out yesterday, with FastMM available, memory management is so much of a solved problem that it’s a non-problem.  So dropping a performance-killing pseudo-GC “solution” on us is patronizing and insulting in the extreme, not to mention a massive waste of effort that could have been spent actually improving the language and/or standard libraries.  But I did notice one very interesting thing from its implementation: the introduction of the [Weak] attribute, and a few other related attributes, are something fundamentally new in the Delphi language. Continue reading ‘How to simplify memory management the right way’ »

NextGen: Delphi’s “Visual Fred” moment?

There’s been a lot of talk recently about immutable strings in the iOS compiler, which, as Marco pointed out, is not actually implemented (yet) but is just something that’s under consideration.  And it appears that he’s uncomfortable with the removal of AnsiStrings.  That’s a good thing, IMO.  I think they should be put back, particularly for UTF-8 strings. Continue reading ‘NextGen: Delphi’s “Visual Fred” moment?’ »

More dwsLinq improvements: query sources and JSON

When I started writing dwsLinq, I never intended it to just be an integrated SQL query builder.  I did that first because it was both useful and easy to implement, but that was never the end goal.

Over the last few days I’ve taken a big step towards the real goal: developing a general-purpose data querying system.  I factored out all of the SQL-specific stuff into its own unit and created an interface called IQueryBuilder that responds to the various query operators to build an expression tree that can be evaluated by DWS.  You create a recognizer and register it with dwsLinq, that checks the value of your FROM expression and returns an IQueryBuilder if it can create an expression for it.  And once I had that working, I created a second unit with a new implementation of IQueryBuilder, for querying JSON data. Continue reading ‘More dwsLinq improvements: query sources and JSON’ »

dwsLinq update: INTO

I just checked in an update to dwsLinq that covers a big step in its progress: the INTO clause.

This is not quite the same thing as INTO in C#’s version of LINQ.  INTO there basically acts as a naming operator, taking a query expression and giving it a name so that you can use it as a sub-expression in further query work.

I did something different with this.  INTO in dwsLinq takes a function pointer as its argument.  The function has to have a single parameter of type Dataset, and return some value, and the INTO clause changes the output of the entire query expression. Continue reading ‘dwsLinq update: INTO’ »

Work in progress: dwsLinq extension for DWS

I’ve always enjoyed the concept behind LINQ: write SQL-esque queries directly in your code, with the compiler able to provide syntactical and type checks, and automatically generate the correct code to do what you wanted.

Unfortunately, there’s nothing like that available for Delphi.  There could be, if the team would shift their focus to augmenting the language with actual useful features borrowed from managed languages, such as a proper extension method implementation, rather that burdening it with useless, counterproductive crap like pseudo-garbage collection and new String models.  But for the time being, we’re out of luck.

It could be done in DWS, but LINQ is a really complex system that makes heavy use of lambdas (aka anonymous methods,) which Eric Grange hasn’t gotten around to supporting yet outside of the JavaScript cross-compilation.  Apparently it’ll take a complete re-architecting of the execution model to make anonymous methods available.

But a while ago, an idea struck me.  In .NET, LINQ uses anonymous methods to support expression class evaluation at runtime.  But DWS is already an interpreted scripting system that operates on an expression tree!  And since DWS has a language extension mechanism in place, I decided to poke around and see what was possible. Continue reading ‘Work in progress: dwsLinq extension for DWS’ »