Any particular reason to not support static thread variables?
A static has a single place in the whole program - single, same memory address. As for a "threadstatic" (or some other name) - we can discuss it. Let's nail down the details - behavior, mechanism - and I'll implement it.
P.S.: Don't rush into implementation. First, it is advisable to analyze all possible scenarios
I try

This single thread is too small to discuss this many different features at once...
@440bx:
Next in line:
Type() - it's a small one.
Feature: atomicThen I have an idea I think is great - I came up with it myself, but then found out other languages have it too, of course... Everything that might be useful is already implemented somewhere: lock / synchronized / std::lock_guard / std::scoped_lock / lock & defer unlock...
FPC Unleashed version:
atomic(optional args) <expr>;Sugar for initCS + enterCS-try-finally-leaveCS-end + doneCS.
atomic inc(i); // lock by source location
atomic(i) inc(i); // lock by "i"
atomic(i, cls) i += cls.value; // lock by multiple vars/objects
atomic begin {...} end; // <expr> can be begin-end
atomic expands to:
1. Init CS in unit/program initialization
2. Done CS in unit/program finalization
3.
atomic: enter CS -> try -> EXPRESSION -> finally -> leave CS
Instead of doing all the initialization and finalization, coming up with a name for the CS, remembering it, entering it, leaving it, and writing the try-finally -
you simply call atomic. IMHO brilliant.
Thoughts?
I created a thread to discuss this specific feature:
Forum: FPC Unleashed: atomic