Arc Forumnew | comments | leaders | submit | almkglor's commentslogin
6 points by almkglor 6423 days ago | link | parent | on: Will/Can Arc create a LISP-revival?

> it's got a canonical implementation

...until you realize that nearly every non-pg, non-rtm Arc user prefers to use the non-canonical Anarki, and recommends it because of the sheer number of bug fixes (never mind the new features, such as 'defcall, 'defm, 'p-m:, 'sync, 'thread-local, 'file-table ... etc.)

> It could make Lisp popular, but it needs some kind of killer app. The news app is cool, but it won't be enough. Anybody's got an idea ?

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

-----

2 points by sacado 6423 days ago | link

Yes, but Anarki's primary goal is still to keep fully compliant with canonical Arc (except for bugs, of course). Now, sure, there are the additions...

-----

4 points by almkglor 6423 days ago | link

There's also the other problem with canonical Arc: pg has expressly stated that he will not retain backward compatibility between versions.

This also means that if Anarki tries to keep full compliance with ArcN in the future, without pg updating ArcN reasonably frequently, eventually (in a year? half a year?) Anarki will either: 1) die out as a source of innovation, because people will simply rather wait for pg's next update rather than push a change that might be overridden by pg in the future, or 2) drift so far away from pg's internal ArcN that when pg releases it, the merge hell will be very, very hot.

Take an example this: http://arclanguage.com/item?id=6138

  arc> (ssexpand 'foo?x)
  (is foo x)
Certainly I could implement that, and I think it's a good idea. The problem is pg's plans: does he intend a different meaning for #\? ? I don't dare to push this on Anarki, because if I do, I don't dare use it anyway, because pg might change its meaning in the future.

Edit: Ah, crick. I wish I can just say "Anarki promises to always keep compatibility with existing Anarki code. If pg breaks existing Anarki code in the next ArcN, we either (1) ignore the new feature, especially if we as a community feel that the existing Anarki feature is better, (2) rename pg's feature if possible, or (3) write a converter for old ArcN-1 based Anarki to ArcN based Anarki. Feel free to program in Anarki, where the magic carpet is assured of not being pulled out under you while you're exploring."

-----

3 points by almkglor 6423 days ago | link | parent | on: arc2c update

Note that a list key is compared using 'iso, not 'is (the quoted list bug notwithstanding)

> There are a few other new things. Most notably, the functional notation for accessing parts of lists/strings/hash tables is now implemented : ('(foo bar baz) 2) returns 'baz.

Cool! How'd you implement it?

I assume it doesn't have support for the 'call* table yet?

-----

3 points by sacado 6423 days ago | link

It looks a little hackish. I implemented it in the END_JUMP macro. If the object in LOCAL(0) (supposed to be a closure) is a string, a table or a cons, perform the adequate lookup operation (taking LOCAL(2) as a parameter). Then perform the actual jump : BEGIN_JUMP, PUSH(LOCAL(1) (which is the continuation)), PUSH(resut of lookup operation), END_JUMP.

call* is not implemented yet.

As for keys in hash tables, I admit I didn't really bother yet. It is quite broken in canonical Arc anyway (and in Anarki too for that matter) : it doesn't work correctly with lists and does not work correctly with strings too (if you update a string key, you're dead). If the hash itself is its own key, it breaks, but I don't know if this is supposed to be feasible or not.

So I'll focus on symbols and numbers as keys, first, as they are the most usual key types anyway, and will gradually introduce other key types.

-----

3 points by almkglor 6423 days ago | link

Just wondering if it's possible to create a bunch of primitives to do the referencing?

  %string-ref
  %list-ref
  %table-ref
Then possibly we could add to lib-ac.scm.arc:

  (= call* (%table)) ;or whatever the table-creating primitive is
  (%sref-table call* 'string
    (fn (s i) (%string-ref s i)))
  (%sref-table call* 'list
    (fn (s i) (%list-ref s i)))
  (%sref-table call* 'table
    (fn (s i) (%table-ref s i)))
  ; for compatibility with existing Anarki
  (set ref
    (fn (c i)
      (if (%is (%type c) 'string)
          (%string-ref c i)
          (if (%is (%type c) 'list)
              (%list-ref c i)
              (if (%is (%type c) 'table)
                  (%table-ref c i)
                  ; dummy stub for error message, when
                  ; errors are implemented
                  ())))))
Then maybe change code-execute* to something like:

  obj fn = SYM2OBJ("fn");
  obj typ;
  goto initjump;
  jump:
  // most common case, so check it first
  if((typ = type(LOCAL(0))) == fn){
    goto realjump;
  } else {
    memmove(&LOCAL(3),&LOCAL(2), (num_args - 2)*sizeof(obj));
    ++num_args;
    LOCAL(2) = LOCAL(0);
    LOCAL(0) = table_lookup(GLOBAL(CALL_TABLE), typ);
    //possibly add a check here to see if it's a function
  }
  realjump:
  pc = LOCAL(0)[0]; //or whichever it should be
  initjump:
  switch(pc){
    ...

-----

1 point by sacado 6423 days ago | link

good idea, I'll implement that soon...

-----


I suggest you try looking at the Anarki repository, which has a few tentative structures for balancing, some steering, and a bit of braking.

-----


> And (def foo a ...stuff...) is just shorthand for (def foo ( . a) ...stuff...).

Technically wrong: ( . a) is invalid syntax. However it does help to think of it that way.

-----

1 point by almkglor 6426 days ago | link | parent | on: WebApp: Only 1st tutorial example works

It's a bug I've experienced on Windows. Apparently the windows command line thinks that the terminal program is not running, so it tries to act based on the input (hence "the syntax of the command is incorrect") but it's actually still running, so both the windows command line and the Arc command line act on your input.

It's a problem with Windows itself ^^

-----

3 points by eds 6425 days ago | link

Actually, "the syntax of the command is incorrect" is due to Arc not using Windows style pathnames. (Also note that the -p option is not valid on Windows.)

  C:\User\Programming\Arc>mkdir -p arc/logs/
  The syntax of the command is incorrect.
Both of these are fixed on Anarki.

-----

1 point by almkglor 6425 days ago | link

ah, interesting ^^

-----

1 point by jkwen 6426 days ago | link

Sweet. Thanks.

-----

2 points by almkglor 6426 days ago | link | parent | on: fork() in Arc

I also added pipes to Anarki.

  (let (input-end output-end) (pipe)
    (...do what you will...))

-----

1 point by almkglor 6426 days ago | link | parent | on: Can we do this with arc macros too?

In principle, yes. To be more specific, you can. Code or it won't happen ^^

Exploratory, exploratory! ^^.

-----

1 point by rincewind 6426 days ago | link

I just wanted to know whether this is possible without using eval. I'll try.

-----

2 points by rincewind 6426 days ago | link

thats it

   (mac spel (name args body)
     `(mac ,name args
       (if (isnt len.args ,(len args))
         (err "wrong number of spel arguments"))
       ((rfn spel-rewrite (b)
         (aif acons.b
           (map spel-rewrite b)
         (pos b ',args)
            args.it
          b)) ',body)))

-----

2 points by almkglor 6426 days ago | link | parent | on: fork() in Arc

I recently added thread-local variables to Anarki (last week or week before last, maybe). To use:

  (= foo (thread-local))
  (foo) ; read the variable
  (= (foo) 42) ; write the variable
Also, I've added semaphores to Anarki. If you want to wait on another thread:

  (let s (sema)
    ; thread you're waiting on
    (thread
      (sleep 1)
      (sema-post s))
    ; monitoring thread
    (sync s)
    (pr 'done))
As mentioned, Anarki only ^^

-----

2 points by eds 6426 days ago | link

Looking at 'sync documentation, it would seem that you can also just call 'sync on a thread to wait for it to end.

  (let th
    ; thread you're waiting on
    (thread
      (sleep 1))
    ; monitoring thread
    (sync th)
    (pr 'done))

-----

1 point by eds 6426 days ago | link

Thanks, that is exactly what I wanted. Although it might be nice to have a macro wrapper around 'thread-local for initializing variables

  (w/uniq void
    (mac w/thread-local (var (o val void))
      (if (is val void)
	  `(= ,var (thread-local))
	  `(do (= ,var (thread-local))
	       (= (,var) ,val)))))
then you could do

  (w/thread-local foo 0)
instead of the two step initialization

  (= foo (thread-local))
  (= (foo) 0)

-----

2 points by almkglor 6426 days ago | link | parent | on: WebApp: Only 1st tutorial example works

A better way is simply this:

  (thread (asv))
    (... work ...)
  (assert quitsrv*)
Then make one last request to the server (it won't terminate until that last one request, because it's stuck listening on the port. yeah, buggy)

For more info on Arc, see kens' excellent guides on http://arcfn.com http://arcfn.com/doc/index.html

-----

2 points by almkglor 6426 days ago | link | parent | on: Big bug in anarki

you'll have to wait for sacado to respond regarding this bit - I believe he's the one who added FFI to Anarki. It's highly possible that the FFI is just not compatible with Windows, and/or the FFI layer in mzscheme is subtly different between Linux and Windows.

-----

1 point by sacado 6425 days ago | link

Yes, I didn't develop windows compatibility for the FFI. I don't have a windows machine to work with. Sorry if it breaks things under windows ... :(

I hope somebody will eventually come with a patch for this. Until then, almkglor's solution seems to work..;

-----

More