Arc Forumnew | comments | leaders | submit | almkglor's commentslogin
2 points by almkglor 6399 days ago | link | parent | on: New types in Arc?

And how do you unlock it for the constructors that are supposed to do the proper locking?

Hmm.

  (let real-annotate annotate
    (def theorem (f)
      (if (check-f-is-valid-theorem f)
          (real-annotate 'theorem f)
          (err "Not a valid theorem")))
    (= annotate 
       (fn (type obj)
         (if (is type 'theorem)
             (err "Spank!  Spank!  Under the boots of your master!!")
             (real-annotate tpye obj)))))
It does have the drawback that you can't, say, reload the file, but hey, you did say you didn't want anyone else to create theorems except by that method, so even redefining that method won't work!

-----

2 points by almkglor 6399 days ago | link

Okay, here's a better way of presenting it:

  (def-B&D-type theorem create-theorem (f)
    (if (check-f-is-valid-theorem f)
        (annotate 'theorem f)
        (err "Not a valid theorem")))
Where def-B&D-type is:

  (mac def-B&D-type (type constructor . body)
    (w/uniq real-annotate
      `(let ,real-annotate annotate
         (let annotate ,real-annotate
           (def ,constructor ,@body))
         (= annotate
            (fn (type obj)
              (if (is type ',type)
                  (err "Spank!  Spank!  Under the boots of your master!!")
                  (,real-annotate type obj)))))))
Note however that even under this, it's still possible to redefine 'check-f-is-valid-theorem.

For that matter, it's still possible to defeat "safety" in language X: just implement a version of language X which doesn't have that safety.

In practice, nobody will bother to do (annotate 'foo something-which-is-not-a-foo) anyway.

-----

1 point by almkglor 6399 days ago | link | parent | on: Dual syntax for Arc

Or just:

  (nfx a + b - c)
An old dorky buggy implementation for CL:

http://www.dwheeler.com/readable/readable/trunk/gloria-infix...

-----


> accessing libraries is rather easy through mzscheme or the experimental FFI (it has to be improved, sure, but it's not that hard if someone wants to)

1. it has to be improved

2. if someone wants to

^^

-----

4 points by almkglor 6399 days ago | link | parent | on: Arc3.tar

And call it "Anarki"

-----

1 point by almkglor 6399 days ago | link | parent | on: Printing squares

As an aside, this appears to be popular, it might be possible to add this to the ssyntax extension.

As an aside, I suspect that much of the slowdown from the new ssyntax/ssexpand comes from scheme-side 'ac emitting a lot of 'ar-eval calls, but I'm not sure, since I haven't studied 'ac output much yet.

-----

2 points by almkglor 6400 days ago | link | parent | on: New types in Arc?

> Hmmh, I don't really think it is against the spirit of the language. After all, I think you cannot just annotate arbitrary things to be of type integer (or can you?).

Yes, you can: (annotate 'int #\newline). It won't be useful, but yes, you can.

> The above solution would surely work in principle, but in practice I create millions of intermediate theorems, I do not want to store all of them!

Standard answer: Garbage collection

In any case: you can always destructure the annotation wrapper and work with the raw data (probably by using some sort of higher-order function, like combinators), only wrapping it in the annotation type. Sort of like explicit monads.

-----

1 point by sacado 6400 days ago | link

Garbage collection does not work here if you keep a track of all the defined theorems in a list as 'known*. We would need weak references to achieve this.

-----

1 point by almkglor 6400 days ago | link

I'm not sure we need a list of defined theorems: apparently the proposed 'modus-ponens function is supposed to accept both source theorems anyway.

-----

2 points by almkglor 6400 days ago | link | parent | on: type dispatching

Yes, this is possible, although you should note that 'defcall is global (do-once-per-program)

-----

1 point by bOR_ 6400 days ago | link

Is it possible to have it in a local way? (per function / module)

-----

1 point by almkglor 6399 days ago | link

No, or rather not yet.

It might be possible to do so by using some sort of dynamic global (a la kennytilton's implementation some time back, but using 'thread-local objects to handle it).

-----

1 point by almkglor 6400 days ago | link | parent | on: Arc3.tar

I'm a baby eater!!! Wahahahahahahahaha!!!!! Phear m3 & my 1337 Baby-eatxor skillz!!!!!!1

-----

1 point by almkglor 6400 days ago | link | parent | on: Printing squares

Where'd you implement 'add-ssyntax-top ? I can't seem to find it anywhere in Anarki.

-----

1 point by absz 6400 days ago | link

Whoops, forgot about that. It's just a thin wrapper around a-ssyntax-top:

  (mac add-ssyntax-top body
    `(a-ssyntax-top ',(pair body [list (string _1) _2])))
. It's just quoting and pairing things. It'd be nice to have a-ssyntax-bottom, too...

-----

1 point by almkglor 6399 days ago | link

I suggest you push this onto Anarki (and possibly implement a-ssyntax-bottom). ^^

-----

1 point by absz 6399 days ago | link

I will do so soon, and hopefully when I get a chance to study ssyntax.arc a little more, I will add a-ssyntax-bottom.

What might be nice would be to have numerical precedence levels (reals, not integers), so that you could add an operator later with the right precedence without redefining everything.

-----

1 point by almkglor 6400 days ago | link | parent | on: Official versions of Arc?

> You can also download Anarki, an unofficial improvement of arc2 (mostly bug fixes, a few experimental ideas and a few more libraries)

Err, I'd say its more (some bug fixes, a lot of crazy experimental ideas and a bunch of unused libraries)

-----

More