Arc Forumnew | comments | leaders | submit | almkglor's commentslogin
1 point by almkglor 3507 days ago | link | parent | on: Lexically shadowing a macro?

  (mac helper (foo)
    `(do ,foo))
  (mac real-macro (bar)
    `(helper ,bar))

  (let helper
       (fn (x) (+ x 1))
    (real-macro (helper 1)))

-----

2 points by rntz 3481 days ago | link

This could be a poster child for hygienic macros.

-----

2 points by almkglor 3543 days ago | link | parent | on: Bind a list of variables

Here's a simple Arc-F package (which is intended to work on hl in the future) that provides pointers.

Pointers are dereferenced by (ptr), so you use (ptr) to get the contents and (= (ptr) v) to assign.

  (in-package pointer)
  (using <arc>v3) ; replace with <hl>v1
  (interface v1
    pointer)
  ; replace with (mac (pointer e) ...)
  (mac pointer (e)
    (if (acons e)
        (let vars (map [uniq] e)
          `(with ,(mappend (fn (var val) `(,var ,val)) vars e)
             ; replace with (tag...)
             (annotate 'pointer
               (cons (fn () ,vars)
                     (fn (v) (= ,vars v))))))
        (w/uniq v
          `(annotate 'pointer
             (cons (fn () ,e)
                   (fn (,v) (= ,e ,v)))))))
  ; replace with (defm (sref (t p pointer)... ) ...)
  (defm sref ((t p pointer) v)
    ((cdr:rep p) v))
  (defcall pointer (p)
    ((car:rep p)))
Usage:

  (= stuff (list (pointer a)
                 (pointer (car b))
                 (pointer c!x)))
  (each p stuff
    (pr (p))
    (= (p) (something)))
If someone's ported nex3's 'defcall and 'defm onto Anarki-on-arc3, the above can be made to work by just removing the package stuff.

-----


Strictly speaking, it doesn't need to be so thorough.

It's possible to make the contexting system be less aggressive about putting symbols in packages.

As an explanation, contexting performs the following transform:

  ; Arc-F code!
  (in-package foo)
  (using <arc>v3)
  (interface v1 public)
  
  (def private (x)
    x)
  (def public (y)
    (private y))
  
  ; equivalent transform!
  t
  t
  t
  
  (<arc>def <foo>private (<foo>x)
    <foo>x)
  (<arc>def <foo>public (<foo>y)
    (<foo>private <foo>y))
Because of its aggression, everything gets to be a pretty thoroughly pushed to some package.

However, you can reduce the aggression instead, at the cost of declaring private functions:

  ; Anarki-on-arc3 code!
  (in-package foo)
  (using <arc>v3)
  (internal private)
  (interface v1 public)
  
  (def private (x)
    x)
  (def public (y)
    (private y))
  
  ; equivalent code!
  t
  t
  t
  t
  
  (def <foo>private (x)
    x)
  (def <foo>public (y)
    (<foo>private x))
In short, instead of assigning unpackaged symbols to the current package, it leaves unpackaged symbols. This retains as much back-portability with ArcN as feasible.

However you still need to force contexting in your REPL/load, i.e. RCEPL, read-contextify-eval-print loop.

I won't be working on Arc-F, since I have my own project now, and stefano is squeezing me to get a REPL on it some time soon ^^

-----

4 points by almkglor 3624 days ago | link | parent | on: HN: (hacked & fixed)

from my lurking, pg has not posted the actual fix to the Arc community.

Since I'm not touching Arc, here's a sketch of what I believe is the problem:

http://news.ycombinator.com/item?id=519521

In the above link, pg describes the problem as being in the fact that he was using "a four variable list to destructure on a five value description of the field."

http://github.com/nex3/arc/blob/8112c99e0cd6f41850910e7c359e...

The above bit of code appears to be the "five value description". It's a function creating a data structure specifically for the particular user and post, making some data showable/not showable and modifiable/not modifiable.

The only time that this particular variable is used is in calls to a 'vars-form function. This function is in app.arc <insert snarky comment about badly disorganized code here>:

http://github.com/nex3/arc/blob/8112c99e0cd6f41850910e7c359e...

The specific "four variable list" appears to be the following line:

http://github.com/nex3/arc/blob/8112c99e0cd6f41850910e7c359e...

The succeeding line has a "(and mod v)" line, which might be correctly "(and mod valid)", where valid is the missing variable in the destructure. <insert snarky comment about pg's Arc-community-building skills here>

-----

1 point by ambition 3617 days ago | link

When investigating for hnacademic.com I came to the same conclusion you did.

Here's the modified code I used on hnacademic.com:

                         (let (typ id val view mod) it
It works, at least for the published crack.

-----

7 points by almkglor 3764 days ago | link | parent | on: Programming Language Design Process

> For example, has anyone has actually tried to write a fast profiler yet?

http://arclanguage.com/item?id=5318

-----

1 point by cchooper 3764 days ago | link

Oops! :)

-----

4 points by almkglor 3767 days ago | link | parent | on: Where are we going?

> continuations, so an Arc-like web server might be more challenging.

Arc's server doesn't actually use continuations - it uses functions that serve as continuatinos. There's no call to 'ccc or any of the wrapping forms in srv.arc (at least none that I remember)

> The concurrency story is particularly interesting given the proliferation of cores and slowing of GHz.

This is true and I think the "extra-cycles-to-waste" property expected by PG isn't going to put out in a hundred years.

> state of the art VM/JIT technology

Forget the libraries. This is what's scary about any JVM language.

-----

1 point by sacado 3767 days ago | link

"Arc's server doesn't actually use continuations - it uses functions that serve as continuatinos. There's no call to 'ccc or any of the wrapping forms in srv.arc (at least none that I remember)"

That's right, no 'ccc. That's why I could implement it so easily in Lua (no real continuation in Lua either). As for TCO, I'm not sure it's a real problem in this case. Sure, a lot of simple functions are written in a recursive style, but they can be trivially rewritten in an iterative style.

-----

2 points by fjl 3748 days ago | link

arc is a movement, not a language.

the primary goal was not to build a language but to get an avalanche of new lisp implementations started.

that lisp is quite easy to implement makes the idea even more compelling.

-----

1 point by almkglor 3768 days ago | link | parent | on: Proposal: concise function definition

  (= f (table))
  (= k 1)

  (= (f k) (+ k 1))
More:

  (def set-the-table (k)
    (= (tb k) (+ k 1)))

  (= tb (table))
-------

file1.arc:

  ; throwaway file I'm playing around with

  ; define some temporary function
  (= (foo x)
     (+ x 1))
file2.arc:

  ; throwaway file I'm playing around with
  (= foo (table))
  (for i 0 3
    (= (foo i) i))
What I do on the command line:

  (load "file2.arc")
  (load "file1.arc")

-----


> But it's worth pointing out that there are work-arounds to a global read table.

How does it handle multiple threads loading code at the same time?

-----

5 points by cchooper 3768 days ago | link

Threads? In Common Lisp? You must be joking!

-----

3 points by almkglor 3768 days ago | link

!!

LOL! ^^ ^_^ >.< ^_^ ROFL!

As an aside, arc-f currently handles loading by wrapping a sizeable bit of 'load in 'atomic, but this is unnecessary, I think, if I use a thread-local for current-load-file* and friends.

-----


> Regarding the use of interfaces to specify the language version: have you ever considered making the language itself a package?

Uh, yes. That's how it's already done. That's why arc.arc is itself a package. In fact, when you say '(in-package foo), the only thing that the contexter will add to the newly-defined package foo are the Arc axioms: '<axiom>fn, '<axiom>if, '<axiom>quote etc. That's why you have to declare '(using <arc>v3) for each package - because otherwise the language doesn't actually import arc.arc

Edit: Ultimately (and this is another disagreement with PG) arc.arc is a library, not part of the language. It's like the libc in this respect. Because you see, we already had the 150-year language 50 years ago.

Edit2: as an aside, the package system even lets you export a binding for 'quote, 'quasiquote, etc. In fact, once we have defined a formal method to add ssyntaxes, it would be possible to add support for `(let foo# ,foo (something foo#)) in a library, not in the language. How? By defining an export for 'quasiquote, say (interface v1 <auto-uniq>quasiquote), where <auto-uniq>quasiquote is a macro that expands to <axiom>quasiquote

> In my opinion the grain should be as fine as possible, so that you can use embedded DSLs whenever possible (like w/html or LINQ).

!!

Hmm. Expression level granularity? Hmm.

-----

1 point by cchooper 3768 days ago | link

Ah yes, I figured because it wasn't in lib/ then it wouldn't be a package.

-----

1 point by almkglor 3768 days ago | link

Hehe. It's in the arc-f/ directory more for historical reasons than because it's not a library, and also because it's treated specially (it gets precompiled to Scheme bytecode, for example).

-----

5 points by almkglor 3769 days ago | link | parent | on: Where are we going?

Did you have to be so crude?

Well I'm also kinda pissed that PG doesn't seem to be noticing anything Arc-related anymore, but his loss IMO.

-----

4 points by silence 3768 days ago | link

Thanks for all your hard work almkglor. I have learned a lot.

-----

More