On Monday, 18 August 2025 at 15:20:14 UTC, Dmitry Olshansky wrote:
>void main() {
startloop();
go({
goOnSameThread({
writeln("Blocking computation");
writeln("Integral:", gauss(0.0, 10.0, x => x*x, 1e-7));
});
});
runFibers();
}
One thing that I think could really be improved about Photon is these funny symbol names.
startloop
is all-lowercase. It's two words so shouldn't it bestartLoop
?go
doesn't actually do any 'go-ing' right away, since fibres are deferred; so it's a little misleading. Maybe it could be more likeschedule
?goOnSameThread
is hyper-explicit compared togo
, but its name still didn't help me understand it until I read the docs. PerhapsgoSync
orscheduleSync
would be more intuitive?runFiber
is an unfortunate victim of the American-English disease. It would be nice to have an alias for 'fibre', which is the spelling used in the rest of the English-speaking world.
Would also be great to have a function named something like 'end loop' that cleans up everything that the library uses internally and allows Photon to be freshly re-initialised with startloop
again later. This would be essential to using Photon in a modular environment. If Photon is no longer needed, then we don't want it hogging resources until the process dies. Obviously calling such a function should not work within a fibre.