Live data from Hacker News

Mariposa – A programming language with time-travel

github.com

1–10 of 63 posts

Re: Mariposa – A programming language with time-travel

#4

Not to be dismissive, but this feels like pointers and lambdas with extra steps.

Well, that's at least a bit reductive. It's all electrons in most programs, but that doesn't mean we don't get advantages from higher level abstractions

Re: Mariposa – A programming language with time-travel

#5
It seems to me like this should be something that can be done using continuations in Scheme. I tried writing the first example:

    (define x 1)
    (define t (now))
    (display x)
    (at t
        (set! x 2))
and trying to implement now and at in a way that would behave correctly. I ran into a wall trying to implement it, because I don't think there is a way to define at that could reference the environment that t was defined in. Maybe a more powerful language like Kernel[0] could implement the same features, but I don't think Scheme can. Very cool!

Also FWIW here is the definition of now and at that I had before I decided to stop:

    (define-syntax now
      (syntax-rules ()
        ((_)
         (call/cc
          (lambda (k)
            (lambda (at-body) (at-body) (k #f)))))))

    (define-syntax at
      (syntax-rules ()
        ((_ instant body1 body ...)
         (instant (lambda () body1 body ...)))))
[0] https://web.cs.wpi.edu/~jshutt/kernel.html

Re: Mariposa – A programming language with time-travel

#7
Okay but why?

Sincerely: what is the pragmatic value?

[edit: NM, end of the page...

> Semantics and correctness of implementation It is not obvious how the Mariposa language could be given a formal semantics. Since there is no specification of its semantics, it doesn't even make sense to ask if the implementation is right or wrong. However, we are sure that the implementation is incorrect for almost any conceivable semantics. It should be understood only as an exploratory game.

]

Re: Mariposa – A programming language with time-travel

#8
post #5

It seems to me like this should be something that can be done using continuations in Scheme. I tried writing the first example: (define x 1) (define t (now)) (display x) (at t (set! x 2)) and trying to implement now and at in a way that would behave correctly. I ran into a wall trying to implement it, because I don't think there is a way to define at that could reference the environment that t was defined in. Maybe a…

You might have to require that any code that uses the now/at constructs be wrapped in a macro invocation, e.g. (with-time-travel ...). The with-time-travel macro would then be a syntax transformer that rewrites the program. I'm not sure how, though... you'd have to enumerate all of the code blocks that are inside "at" forms, and then conditionally dispatch to them in the expansion of the "now" form; but that doesn't quite work because (now) is a value, and so figuring out which "at" forms consume it is probably undecidable. You can't have all the cases in the expansion, either, because of the incompatible environments.

It's an interesting problem, but one that I think is ok not to be able to solve in Scheme.

Re: Mariposa – A programming language with time-travel

#9
post #5

It seems to me like this should be something that can be done using continuations in Scheme. I tried writing the first example: (define x 1) (define t (now)) (display x) (at t (set! x 2)) and trying to implement now and at in a way that would behave correctly. I ran into a wall trying to implement it, because I don't think there is a way to define at that could reference the environment that t was defined in. Maybe a…

You might have to require that any code that uses the now/at constructs be wrapped in a macro invocation, e.g. (with-time-travel ...). The with-time-travel macro would then be a syntax transformer that rewrites the program. I'm not sure how, though... you'd have to enumerate all of the code blocks that are inside "at" forms, and then conditionally dispatch to them in the expansion of the "now" form; but that doesn't…

It's only legal for each `now` to be consumed by at-most one `at` form, so at that point you'd just be re-implementing the "timeline" and "instant" system from mariposa. The need to wrap the program in a form and the management of `now` "values" has me pondering the implications of IanTheHenry's macaroni[1] system, which (like the CSS :has operator) allow macros to climb up into manipulations of their parent forms-- the `now` macro could effectively wrap every remaining form in the program with a new context that augments eg. the closure of `at`. But indeed, perhaps a problem to not become too invested in :p

1: https://github.com/ianthehenry/macaroni

Post reply on HN