Hacker News new | ask | show | jobs
by roriau 202 days ago
You're correct if Context is hidden or implicit (like Dependency Injection containers or ThreadLocals in Java), it becomes debugging nightmare.

To solve this, SFX treats the Context Stack as Explicit Data, not hidden magic.

1. Debugging: Because the runtime knows exactly what 'Reality' is active, we can print it. We are building a `Context.Trace()` tool that outputs something like: `[Base Reality] -> [HolidaySale] -> [AdminMode]` This tells you exactly why a method is behaving the way it is.

2. Layering: Yes, contexts are strictly layered (LIFO stack). If you activate `Situation A` then `Situation B`, the runtime checks `B` first, then `A`, then the Object itself. This allows for 'Behavioral Inheritance'—you can compose behaviors (e.g., `LoggingMode` + `SafeMode`) dynamically.

3. Scoping: Right now it is imperative (`Switch on/off`), but because SFX is indentation-based, we are working on block-scoped contexts for the next release:

    Using AdminMode:
       User.Delete()  # Admin context
    # Automatically reverts here
    
Thanks for the encouragement.