ADUG Melbourne Meeting July 2024

Hi Everyone,

The Melbourne ADUG July meeting is on Monday Night, 15th July

John McDonald will show some techniques from functional programming that can be used in Delphi for processing lists and other collections. He’ll
use spring4d collections that make this much simpler.

When: 6:00pm for a 6:15pm start
Where: At the Melbourne Men’s Shed, and on Zoom.

Zoom link will be up here shortly before the meeting starts.

1 Like

Join Zoom Meeting
Launch Meeting - Zoom
Meeting ID: 810 0076 0178
Passcode: 553438

One tap mobile
+61731853730,81000760178#,*553438# Australia
+61861193900,81000760178#,*553438# Australia

Dial by your location
• +61 7 3185 3730 Australia
• +61 8 6119 3900 Australia
• +61 8 7150 1149 Australia
• +61 2 8015 6011 Australia
• +61 3 7018 2005 Australia
• +1 312 626 6799 US (Chicago)
• +1 346 248 7799 US (Houston)
• +1 360 209 5623 US
• +1 386 347 5053 US
• +1 507 473 4847 US
• +1 564 217 2000 US
• +1 646 558 8656 US (New York)
• +1 646 931 3860 US
• +1 669 444 9171 US
• +1 669 900 9128 US (San Jose)
• +1 689 278 1000 US
• +1 719 359 4580 US
• +1 253 205 0468 US
• +1 253 215 8782 US (Tacoma)
• +1 301 715 8592 US (Washington DC)
• +1 305 224 1968 US
• +1 309 205 3325 US
Meeting ID: 810 0076 0178
Passcode: 553438
Find your local number: Zoom International Dial-in Numbers - Zoom

Thanks @johnmcd a very informative presentation on usage of Spring4D.

Here John pointed out the lack in Delphi of Generic methods on Interfaces …
(and also a want for an improvement in type inference around generic functions with generic or function arguments)
(ie WeatherList.Select( TWeatherFns.MinTemp ) would be much nicer)

((PS : hey John … if you think of any specific sub-optimal uses of fluent style, I’d love to study them.))

From Alister, somewhat related to a point @johnmcd was making about missing const parameter cases … (with IEnumerable I think)

The spring.pas unit from Spring4d defines generic Func, Proc, Action and Predicate method reference types with const parameters. Note: no T in the type name.

These can be used in place of the corresponding TFunc, TProc, TAction and TPredicate types defined in SysUtils.

1 Like

Conrad Vermeulen, who is part of the Uk Dev Group … and spoke at the Delphi Summit … may be able to talk to ADUG in the future.

This library is inspired somewhat by Linq …

Looks like he has given up on that library, marked the repo as read only.

Yes. Recently I think.

Sorry for the delay, I had to spend some time trying to get my head
around what John had done, and still not totally sure.

Seemed almost like a bit of black magic in there…

John retrieved a set of country data into a Spring4D list, and then
using Spring4D’s IEnumerable iterator functionality was able to filter and
Sort the list in clever ways. How he did this was interesting, and not
in a way I would even think of, much less use, but maybe one day
soonish…

Back on the IEnumerable iterator, it seems to have many methods that I
could relate to. They had names like Select, Union, Or, And, First,
Order.

So I could likely do things with this list in a similar way to what I
might with an SQL query.

Apparently you could have multiple views? on the same IEnumerable??

Back to the IEnumerable processing.
For selecting items, I would perhaps write something like.

Result := True;

if Result and UseCriteria1 then Result := ApplyCriteria1(Params1);
if Result and UseCriteria2 then Result := ApplyCriteria2(Params2);
if Result and UseCriteria3 then Result := ApplyCriteria3(Params3);

A true result would result in the row/item being included.

John was instead creating a function at runtime using anonymous methods,
that only included/performed the required tests.

eg. Assuming only UseCriteria2 was True, the method that would be
created would only contain something like.

Result := True;
if Result then Result := ApplyCriteria2;

And the Params2 argument is actually supplied when the anonymous method was created.

This reminds me a little bit of building SQL on the fly and applying it.
It seemed to work well.

Thank you John,
I definitely have some more learning to do…

1 Like