Arc Forumnew | comments | leaders | submitlogin

Yeah you're welcome to do so. I meant only that any changes we make don't get pushed to this particular instance of the forum. But it's totally doable to say bring up a free AWS micro instance.

It's up to you. I prefer to bind a consistent identity everywhere.
2 points by rocketnia 4907 days ago | link | parent | on: Elm: FRP in the browser

Elm's examples make it easy to tweak the code and send it off to their server for immediate compilation, which is a pretty fun way to get started with FRP. :) I was able to follow the instructions to get Elm installed on my own computer too. I've encountered a lot of pain trying to set up Haskell GUI bindings, so this puts Elm at a distinct advantage relative to Haskell FRP libraries.

The Elm project has a lot in common with Flapjax, another FRP language. However, Flapjax automatically lifts expressions like "a + b" to return signals if the arguments are signals, whereas Elm just acts as a Haskell-like FRP library plus a Haskell-like language to use it in. In Elm, there's an explicit family of lift, lift2, lift3, ... operators for mapping an n-arg function over n Signals.

                                   Elm                   Flapjax
                          ---------------------   ---------------------
  Maintained in:           Haskell and some JS     Haskell and some JS
  Compiler runs in:              Haskell                   JS
  Application runs in:             JS                      JS
  Syntax approximates:           Haskell                   JS
  Expressions represent:         Values             Signals or Values
So far I've shied away from exploring Flapjax because its syntax is too deeply interlinked with JS. I'm not really sure how my synchronous-looking, side-effect-laden code will play out when some (but not all!) of its expressions represent time-varying values. Since Elm's syntax is more Haskell-like, I feel it can avoid inheriting JavaScript's quirks and be more faithful to the necessary semantics. If only Elm had a convenient syntax for transforming signals, such as Flapjax, GHC's Arrow syntax, or the arrow calculus.

Elm's interaction with JavaScript code seems like it could use some improvement, which matters because I care about using new Web standards as they come out. Fortunately, it's not so bad that it makes the language unusable for this purpose, and I have an idea for how to prototype a new FFI from within the existing one. I'll elaborate on that idea in a separate post.


Still too big a question. It also needs elaboration. Why only? Why does efficiency matter? What are some examples of what you mean by this? How do you surmise programming might help?

I'm not sure what to say. You can't judge coolness from data. Lateral thinking isn't necessary for programming. Sometimes it just takes a long time to understand; simplicity in hindsight is an illusion. What do you mean by anti-hacks?

'Paul and Robert' don't come here anymore; we hang out here, but we can't make improvements. We could setup a new site, but the issues so far seem too minor to push us to that.

You can learn more by doing, and by asking for more concrete help. I doubt I can help with the big questions, but I can try to help with smaller ones. Is there something you would like to build?

1 point by akkartik 4909 days ago | link | parent | on: Common Lisp koans

"For any aspiring koan writers, Arc and Scheme lack koans." https://news.ycombinator.com/item?id=5803678

Ah yes, excellent catch:

https://github.com/Pauan/ar/commit/95f13f757a52a5d07f5467603...

1 point by dram 4914 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Thanks, well done.

Thanks for the commit! I've merged https://github.com/arclanguage/anarki/commit/1bc954f598 and given you commit rights to anarki.

I've also added/plagiarized rainbow's tests to the repo: https://github.com/arclanguage/anarki/commit/68be3c0f4d. Joys of the perl artistic license.

There's still a couple of syntax tests that are failing, likely because of test harness issues. And I'd like to unify all the different tests into a single framework. For future work..

---

Update 43 minutes later: it turns out rainbow's ssyntax precedence rules were different. Perhaps anarki changed at some point. Those tests are now fixed.

3 points by dram 4915 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Your fix is cleaner. :)

BTW, I think `(unescape-ats s)` also needs to be treated as the same.

So that it will not fail when atstrings is set.

2 points by dram 4915 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Great!

I'll make a pull request later.

3 points by Pauan 4915 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Fixed in Arc/Nu:

https://github.com/Pauan/ar/commit/a2c1939936846b665eccf06d0...

Thanks for finding the bug, and the great idea for fixing it.

1 point by lark 4915 days ago | link | parent | on: How do you use keyword parameters in Arc?

Thanks for the cool tricks. These will work.

That's a good idea. Did the tests pass without your changes?

I've added a few piecemeal tests over the years (all the .t files in the repo), and there's also some tests in my curated repo (http://github.com/akkartik/arc). All those seem ok..

---

Looks like dfn is a rainbow innovation: http://arclanguage.org/item?id=10539

---

Update 1 hour later: almost all rainbow tests pass! I had to disable the dfn tests, and the ssyntax tests at the bottom of core-evaluation-test were hanging. Other than that it's all good.

2 points by dram 4915 days ago | link | parent | on: Failed to modify strings in latest mzscheme

OK.

I'd like to run some tests to make sure it does not cause much problem.

I found this one:

https://github.com/conanite/rainbow/tree/master/src/arc/lib/...

But it failed with following error when using arc3.1.

  arc> (load "unit-test.arc")
  nil
  arc> (rat)
  Error: "_dfn: undefined;\n cannot reference undefined identifier"

Ingenious! Do you have a github account? You should be the one to fix this in anarki :)
4 points by dram 4915 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Yes, That is the problem!

Here is a quick and dirty patch for arc3.1, it postpones string-copy and let it run by eval.

Not sure if it will cause some other problem.

  50,51c50,51
  <           (unescape-ats s))
  <       (string-copy s)))          ; avoid immutable strings
  ---
  >           `(string-copy ,(unescape-ats s)))
  >       `(string-copy ,s)))          ; avoid immutable strings

Yeah, very strange.

In ac.scm, in the arc compiler ac, arc strings are translated using ac-string. I've tried instrumenting the output of ac-string, and it seems mutable when it's encountered. And yet it's immutable by the time I return to the prompt:

  arc> ($.immutable? "abc")
  #f  # printed inside *ac-string*
  #t  # return value
Very strange.

---

I tried bisecting the git history, and the stable branch, which still requires mzscheme, has mutable strings. But sometime in 2011 when the master branch switched to using racket and stopped working with mzscheme, strings went immutable again. Still investigating..

---

Back in Feb 2011, waterhouse provided a bugfix for arc's mutable pairs. http://arclanguage.org/item?id=13616. https://github.com/arclanguage/anarki/commit/cea8a4c5e9. This change requires a racket-only lib, and so arc stopped working with the old mzscheme versions. Prior to it, modifying strings worked in mzscheme but not in racket. So it seems to be something about the move from mzscheme 372 to racket.

---

Update 34 minutes later: It seems eval in racket emits immutable strings even when given mutable strings. Since everything passes through racket's eval it doesn't matter how much arc twists and turns to avoid immutability.

  $ racket
  > (immutable? "abc")
  #t
  > (immutable? (string-copy "abc"))
  #f
  > (immutable? (eval (string-copy "abc")))
  #t
3 points by dram 4916 days ago | link | parent | on: Failed to modify strings in latest mzscheme

Find this thread in plt-scheme mailing list that pg posted several years ago.

http://comments.gmane.org/gmane.lisp.scheme.plt/14787

It seems that this problem had once been solved, but occurred again.


I've been maintaining a fork with keyword args: http://github.com/akkartik/arc. Wart has them as well.

Racket has ways to create mutable strings: http://docs.racket-lang.org/reference/strings.html#%28def._%...

But it's not immediately clear to me how to use them in arc.

2 points by zck 4916 days ago | link | parent | on: Failed to modify strings in latest mzscheme

This is also a bug in Racket 5.2.1, although with a different error message:

  arc> (= (s 0) #\m)
  Error: "string-set!: expects type <mutable string> as 1st argument, given: \"foo\"; other arguments were: 0 #\\m"
1 point by Pauan 4916 days ago | link | parent | on: How do you use keyword parameters in Arc?

"[...] or a way to add them easily?"

Arc/Nu used to have keyword arguments, but they were a pain in the butt to implement, and only a single function actually used them, so I took them out.

So, it's possible, yes, but not easy. At least, not easy using Racket's keyword arguments. It might be easier if I did everything from scratch...

3 points by zck 4916 days ago | link | parent | on: How do you use keyword parameters in Arc?

Well, it depends if you're talking vanilla Arc, or a different implementation.

If you want to go with base Arc, you can pass a dictionary in, something like this:

  (def greet ((o arg-dict (obj)))
       (prn "Hello there, "
            (or arg-dict!person "friend")
            "! Would you like "
            (or arg-dict!thing-to-offer "some ice cream")
            "?"))
  
  arc> (greet)
  Hello there, friend! Would you like some ice cream?
  "Hello there, "
  arc> (greet (obj person "Darth Vader" thing-to-offer "a lightsaber"))
  Hello there, Darth Vader! Would you like a lightsaber?
  "Hello there, "
  arc> (greet (obj thing-to-offer "two lightsabers"))
  Hello there, friend! Would you like two lightsabers?
  "Hello there, "
  arc> 
You could, I suppose, treat a rest argument as a list of (keyword argument) pairs:

  (def greet2 arg-list
       (let args (pair arg-list)
            (prn "Hello there, "
                 (or (alref args 'person) "friend")
                 "! Would you like "
                 (or (alref args 'thing-to-offer) "some ice cream")
                 "?")))
  
  arc> (greet2)
  Hello there, friend! Would you like some ice cream?
  "Hello there, "
  arc> (greet2 'person "Darth Vader" 'thing-to-offer "a lightsaber")
  Hello there, Darth Vader! Would you like a lightsaber?
  "Hello there, "
  arc> (greet2 'thing-to-offer "two lightsabers")
  Hello there, friend! Would you like two lightsabers?
  "Hello there, "
  arc> 
Note: this has no error checking, but the failure mode isn't awful:

  arc> (greet2 'person)
  Hello there, friend! Would you like some ice cream?
  "Hello there, "
  arc> 
You can mix this with required parameters:

  (def greet3 (emotion . arg-list)
       (let args (pair arg-list)
            (prn "Hello there, "
                 (or (alref args 'person) "friend")
                 "! I'm " 
                 emotion
                 " to see you. Would you like "
                 (or (alref args 'thing-to-offer) "some ice cream")
                 "?")))
  arc> (greet3 'happy)
  Hello there, friend! I'm happy to see you. Would you like some ice cream?
  "Hello there, "
  arc> (greet3 'enraged 'thing-to-offer "to be murdered")
  Hello there, friend! I'm enraged to see you. Would you like to be murdered?
  "Hello there, "
  arc> 
I haven't used these; I've merely come up with them on the spot. No doubt other people have come up with better ideas.

Downsides include not having a good way to set defaults -- you have to supply the default each time in the code you use it. Alternately, you can put the body in a function that requires each argument, then in the "regular" function, supply the default as an argument to the helper:

  (def greet4 (emotion . arg-list)
       (let args (pair arg-list)
            (greet4-helper emotion
                           (or (alref args 'person)
                               "friend")
                           (or (alref args 'thing-to-offer)
                               "some ice cream"))))
  
  (def greet4-helper (emotion person thing-to-offer)
       (prn "Hello there, "
            person
            "! I'm " 
            emotion
            " to see you. Would you like "
            thing-to-offer
            "?"))
  
  arc> (greet4 'bored)
  Hello there, friend! I'm bored to see you. Would you like some ice cream?
  "Hello there, "
  arc> (greet4 'bored 'thing-to-offer "to go away")
  Hello there, friend! I'm bored to see you. Would you like to go away?
  "Hello there, "
  arc> 
Note that you can't explicitly pass nil this way:

  arc> (greet4 'bored 'thing-to-offer nil)
  Hello there, friend! I'm bored to see you. Would you like some ice cream?
  "Hello there, "
  arc>

Create a separate VirtualHost in your apache config with a ServerName of news.myname.com, etc. I haven't done this precise configuration before, but Googling brings up howtos like https://httpd.apache.org/docs/2.2/vhosts/examples.html.

Two more metrics:

		Source/Medium - Visits
 	
	1.	(direct) / (none) - 1,240
	2.	google / organic - 1,130
	3.	en.wikipedia.org / referral - 695
	4.	nicholasblee.com / referral - 167
	5.	arclanguage.org / referral - 129
	6.	tryarc.org / referral - 114
	7.	arcueid-arc.org / referral - 61
	8.	reddit.com / referral - 49
	9.	news.ycombinator.com / referral - 45
	10.	lambda-the-ultimate.org / referral - 37

		Landing Page - Visits
 	
	1.	/site/arclanguagewiki/ - 1,811
	2.	/site/arclanguagewiki/getting-started/install-arc - 617
	3.	/site/arclanguagewiki/more/avl-trees - 487
	4.	/site/arclanguagewiki/getting-started/tutorial - 310
	5.	/site/arclanguagewiki/home - 160
	6.	/site/arclanguagewiki/arc-3_1/known-bugs-and-gotchas - 155
	7.	/site/arclanguagewiki/more/list-of-languages-with-s-expression-sugar - 80
	8.	/site/arclanguagewiki/getting-started/installing-emacs - 64
	9.	/site/arclanguagewiki/more/keyword-arguments - 31
	10.	/site/arclanguagewiki/arc-3_1/optimizations - 27


For the me the number that stands out is:

   arclanguage.org / referral - 129
That's a paltry 129 coming from what should be the mother lode.

So here is my appeal, pg, if you are listening:

Please update these two pages - http://www.arclanguage.org/install and http://www.arclanguage.org/ - just that wee bit, and put a link to https://sites.google.com/site/arclanguagewiki/. It would make quite a difference to the Arc community, and take only a few minutes of your time. Please?


"An implementation of intermediate splicing would be something like[...]"

Which of these interpretations do you mean?

  (list 1 2 (splice 3 4) 5)
  -->
  (list 1 2 3 4 5)
  
  
  (list 1 2 (splice (reverse (list 4 3))) 5)
  -->
  (list 1 2 3 4 5)
I wrote the rest of this post thinking you were talking about the first one, but right at the end I realized I wasn't so sure. :)

---

"Namely, making the lists that form the code/ast have reverse links, so you can mutate above the macro call level, instead of just insert arbitrary code in place."

I'll make an observation so you can see if it agrees with what you're thinking of: The expression "above the macro call level" will always be a function call or a special form, never a macro call. If it were a macro call, we'd be expanding that call instead of this one.

---

For these purposes, it would be fun to have a cons-cell-like data structure with three accessors: (car x), (cdr x), and (parent x). The parent of x is the most recent cons-with-parent to have been constructed or mutated to have x as its car. If this construction or mutation has never happened, the parent is nil.

Then we can have macros take cons-with-parent values as their argument lists, and your macro would look like this:

  (mac splice list
    (= (cdr list) (cdr (parent list)))
    (= (cdr (parent list)) list))
Unfortunately, if we call (list 1 2 (splice 3 4) 5), then when the splice macro calls (parent list), it'll only see ((splice 3 4) 5). If it calls (parent (parent list)), it'll see nil.

---

Suppose we have a more comprehensive alternative that lets us manipulate the entire surrounding expression. I'll formulate it without the need to use conses-with-parents or mutation:

  ; We're defining a macro called "splice".
  ; The original code we're replacing is expr.
  ; We affect 1 level of code, and our macro call is at location (i).
  (mac-deep splice expr (i)
    (let (before ((_ . args) . after)) (cut expr i)
      (join before args after)))
If I were to implement an Arc-like language that supported this, it would have some amusingly disappointing consequences:

  (mac-deep subquote expr (i)
    `(quote ,expr))
  
  
  (list (subquote))
  -->
  (quote (list (subquote)))
  
  
  (do (subquote))
  -->
  ((fn () (subquote)))
  -->
  ((quote (fn () (subquote))))
  
  
  (fn (subquote) (+ subquote subquote))
  -->
  (fn (subquote) (+ subquote subquote))

This relates to yet another idea I think I've actually mentioned before.

Namely, making the lists that form the code/ast have reverse links, so you can mutate above the macro call level, instead of just insert arbitrary code in place. This wouldn't be feasible for general lists, as it is possible for a sub-list to be referenced in more than one place, but for code, each piece is generally considered unique even if it looks the same.

Anyway, this would allow for affects ranging from splicing to arithmetic and other much more evil and nefarious but possibly useful effects. I haven't thought through all of the implications, and I bet most of them are negative, but it would still be interesting to consider.

An implementation of intermediate splicing would be something like:

  (mac (list)
    (= (cdr list) (cdr (parent)))
    (= (cdr (parent)) list))
Where you replace (parent) with whatever technique would get the parent cons cell whose car is the macro call.

Yes, that is part of the reason I like them so much. The other part is that they're a way to legally use bare words as part of the syntax.

If json had a symbol type, Wat would be a lot less ugly.


"Doesn't step 1 need to use environment(s)?"

I think he's talking about run-time environments a la Kernel, Emacs Lisp, etc.

Nulan and Arc/Nu use a compile-time environment to replace symbols with boxes at compile-time. But that feels quite a bit different in practice from run-time environments (it's faster too).

---

"Are you suggesting a third thing we could insert here?"

Once again, I think he's referring to run-time environments. Basically, what he's saying is that you would use boxes at compile-time (like Nulan), but you would also have first-class environments with vau. The benefit of this system is that it's faster than a naive Kernel implementation ('cause of boxes), but you still have the full dynamicism of first-class run-time environments. I suspect there'll be all kinds of strange interactions and corner cases though.

---

Slightly off-topic, but... I would like to point out that if the run-time environments are immutable hash tables of boxes, you effectively create hyper-static scope, even if everything runs at run-time (no compile-time).

On the other hand, if you create the boxes at compile-time, then you can create hyper-static scope even if the hash table is mutable (the hash table in Nulan is mutable, for instance).

More