Recent

Author Topic: FPC Unleashed (inline vars, statement expr, tuples, match, indexed/lazy labels)  (Read 35439 times)

Fibonacci

  • Hero Member
  • *****
  • Posts: 949
  • Behold, I bring salvation - FPC Unleashed
Consider this simple example:

<cut>

after some time, could be months or years, someone decides to add a field to TREC_1, like this:

<cut>

now there is a naming conflict with SomeOtherField. Where is the conflict resolved, in the new TREC_1 or in TComposed ?  The potential for this problem grows as the number of unnamed embedded records grows in the composed record(s).

<cut>

Did that clarify the situation ?

No. I get what you're pointing at, but it only matters in one specific case: if you assume coders are stupid. Are they?

The error is:
Error: Duplicate identifier "SOMEOTHERFIELD" from composition - already present in the surrounding record
(screenshot attached)

That's verbose enough to tell exactly what's wrong, where it came from, and what to fix. No archaeology required, no scrolling through "hundreds of lines or different files" to find the conflict - the compiler hands the answer over on the first build after the change. The maintainer reads "duplicate identifier from composition" and knows immediately what to do.

Yes, the surface for this grows with each anonymous embed. But the surface for any failure mode grows with each new line of code. What matters is whether the failure is silent (bad) or loud (good). This one is loud, the message is informative, and the fix is local.

Where you see a "can of worms", a "house of cards" and a "poison pill", I see great potential. Real use cases - I actually can't wait until it's merged into main, so I can start building projects with it. This feature gives real "record-freedom" - not just the embed, but the feature as a whole. Freedom - that is what I see, and feel.



I really see no value in that feature but only problems.

I've wanted something like this since @Warfley presented his "Record Composition" - his implementation has the same exact thing, anonymous embed, just named differently. You don't see the value, but I (and I hope others) do. This feature was my little dream.

I've said enough about how "free" I feel having it - as a whole, not just embed on its own. It's a massive addition - it enables really cool structures, like ones with a common header/footer.



But I can see I won't convince you - oh well, I'm not going to keep fighting this. Your preference, fair enough. The feature isn't for you, you don't have to use it, you don't have to test it.

I hope someone else will. Maybe they'll find a bug, maybe suggest an improvement, maybe spot something I missed. As I wrote earlier - I expect bugs. Or maybe there are none. Or maybe they'll surface over time. Or I'll find them myself.

Let's end this little embed war here. Give it a few days, then I'll merge to main and we can move on to other changes/fixes. I hope you won't drop Unleashed over this - records still work exactly as before, this is just an addition. You don't have to use it.



Update on the installer timeline: I'll publish it tomorrow, not today. Too late in the day for that, and this discussion took too much of my energy :o
FPC Unleashed - inline vars, tuples, statement expressions, array equality, compound assignments, indexed/lazy labels, no-RTTI & more. ⭐ Star it on GitHub!

440bx

  • Hero Member
  • *****
  • Posts: 6488
Just to clarify a few things,

1.  I don't think coders are stupid, I just think they make mistakes, just as I do.  No difference.

2. We definitely have diametrically opposed opinions as to how valuable the feature is.  I went through all the trouble of explaining in detail because a. you asked for it and b. I thought you didn't realize the potential problems as a result of a simple mental lapse.  I realize now, you are fully aware of the problems yet, still value it.  That's fine with me, I have no problem with that but, as you correctly pointed out, it definitely isn't for me.

3. I wasn't fighting.  I was doing my best, in good faith, to point out the problems I see because I thought they might have escaped you.  Sometimes I fail to see the obvious and I've seen that happen to other people too, not just me.  I thought this was one of those instances.  It was not a fight.

Keep up the good work, there is lots to appreciate in what you've added to the language so far.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018