carp-lang / carp-lang/Carp

References must keep track of their origin

Open
#470 4 comments 1 reaction 1 assignee View on GitHub

@eriksvedang is already working on this.

Since May 30, 2019.

bug difficult haskell memory
Dominant language
Haskell
Stars
6k
Forks
187
Avg merge
8d 22h
Merged PRs (30d)
4

Description

Currently, references can be invalidated by invalidating their origin inside their scope.

(defn use-up [x] ())

(defn main []
  (let-do [a [@"hi"]
           n (Array.nth &a 0)]
    (use-up a)
    (println* n))) ; we used a already! this is bad!

It is also possible to set references to point to values in a more short-lived scope:

(defn main []
  (let-do [x ""]
    (let [a [@"hi"]]
      (set! x (Array.nth &a 0)))
    (println* x))) ; a was already dropped!

Both of these can be prevented by checking the origin of a reference and whether the origin scope still exists; an error could be emitted if it doesn’t.

Cheers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.