3 ms·
Just because you can algorithmically desugar doesn't mean you can invert that transformation. The property you're looking for is invertibility, not idempotence
by shriramkmurthi 12y ago
Just because you can algorithmically desugar doesn't mean you can invert that transformation. The property you're looking for is invertibility, not idempotence (which neither follows nor is relevant), and it doesn't follow.
As for the power of the desugaring system, you apparently decided to just ignore my first paragraph as an inconvenient truth. I could repeat it. But I can give you even simpler examples that are well-known as canonical examples of the genre: C++ templates, Scheme macros. Scheme's macros are about as simple a desugaring system as you could want. And yet even its _simplest_ version — too weak to express many of the language's constructs, way weaker than Racket's — is Turing-complete. I don't even know what you're talking about with "finite" sugars (all programs are finite by definition, but that doesn't imply anything about their dynamic properties).
I'm guessing haven't really thought about this problem much and are just speculating casually. You might want to read work like
http://cs.brown.edu/~sk/Publications/Papers/Published/pk-resuarging/ http://cs.brown.edu/~sk/Publications/Papers/Published/pk-res...
which shows some of the complexity involved. (Just to make you happy, the desugaring in this paper uses about as "simple" a desugaring mechanism as you could want. And it is about an extended version of precisely the problem of undoing desugaring, hence the name "resugaring".) Once you've understood this material we'd be in a position to actually have a meaningful conversation.
- Dylan16807 12y agoI'm not looking for the ability to strictly invert, I'm looking for the ability to make a canonical sugaring. desugar+resugar may or may not give me the same as the original, but it will be idempotent. Scheme macros? Oh wow we really are talking about completely different things. I'm talking about fixed transformations that are part of the language (just like the original comment seems to be, as far as I can tell), not arbitrary user-supplied transformations. And I admit that I'm coming at this rather casually, but I'm considering languages I've used that have very little sugar and writing this sort of mechanism would be easy. I looked at that paper a bit, they're tackling a very hard problem by taking languages with complex sugar and making a program that automatically processes sugar into an algorithm for resugaring. That's much harder than codesigning language and sugar to be amenable to resugaring.