Arc Forumnew | comments | leaders | submit | absz's commentslogin
1 point by absz 6030 days ago | link | parent | on: Brainstorm: syntax sugar for lambdas

Unfortunately, this is then deoptimized for the most common one-argument case, where you have to write [... _.0 ...]. We could have [...] expand to (fn __ (let _ (car _) ...)), so that you would have

  (reduce [- (/ __.1 (* 2 __.0))] mylist)
but still have

  (map [+ _ (* _ _)] myotherlist)
. I still prefer the _1, _2, ... syntax, though---unsurprisingly, as I contributed that implementation (though not the idea) :)

-----

1 point by shader 6030 days ago | link

Actually, I do think the _1, _2 .. syntax makes the most sense, if you aren't wanting to name parameters. Though maybe (as was mentioned above) in some cases, the first three should be a b c, or x y z? I don't know how you would set that up to work well with what already exists though.

-----

6 points by absz 6062 days ago | link | parent | on: Remove lib/spec.arc - license violation

If that's the case, we have a much larger problem. From the "copyright" file:

  This software is copyright (c) Paul Graham and Robert Morris.  Permission
  to use it is granted under the Perl Foundations's Artistic License 2.0.
This is from arc2.tar (and thus Anarki as well). Thus if that's true about the Artistic License, all of Anarki is in violation. According to Wikipedia (http://en.wikipedia.org/wiki/Artistic_License), however, the Artistic License 2.0 is both free and open source---in fact, it's GPL compatible, and perl itself is dual-licensed under both of said licenses. Thus, I would think we would be OK.

It's a bit late/early and IANAL, but my reading of the Artistic License is that we are OK given section 4. Section 4 says that we can distribute modified versions of the source provided we document the differences and either: (a) make the modified version available to the original creator under the original license; (b) ensure that one can install both the modified and original versions separately and that the modified one has a different name; or (c) allow redistribution of the source under either this license or another free license. We're definitely doing (a) and (c) and we're probably doing (b), so if I understand this correctly, we should be in the clear.

Thoughts on this interpretation? This is much bigger than just one library, after all...

-----

5 points by almkglor 6062 days ago | link

Your interpretation seems accurate.

This of course means we really need to document Anarki and Arc-F quite well.

-----

3 points by bOR_ 6062 days ago | link

Somewhat annoying, as doing a 'diff' is probably not enough.

It'll also become slightly messy if pg's statement from a month ago becomes true, and there will be new versions of arc coming out in october / november. If we pick up features from different versions of arc, would the changes compared to arc2, as well as the changes compared to arc3 need to be documented.

I guess the value of forcing good documentation of the changes is that it becomes easier for pg to distill a new arc version out of the mutants that the community is spawning, as they'll have their features well documented.

-----


The deal with path separators has to do with the difference between the classic Mac OS (9 and lower) and Mac OS X. Classic Macs used their own path system, which used :s as the path separator (e.g., ":Macintosh HD:Documents:Arc:tut.txt"). When the switch to OS X came, suddenly everything was based on Unix, so file paths became sane (e.g., "/Users/username/Documents/Arc/tut.txt" or even "~/Documents/Arc/tut.txt"). Nevertheless, in the name of backwards compatibility, many things still display paths in the old format, the GUI pretends that :s in file names are actually /s, and AppleScript deals natively with old-style filenames.

In a nutshell: OS X sane, Classic Macs crazy.

-----

3 points by absz 6064 days ago | link | parent | on: A thought: Arc <=> JS

There is http://arclanguage.org/item?id=1629 (http://halogen.note.amherst.edu/~jdtang/arclite/), which is similar to what you mention; however, it's old now.

-----

5 points by andreyf 6064 days ago | link

Cool, but I was thinking more something which would simply translate

    (foo "bar" 1 2)
into

    foo("bar", 1, 2)
One motivation is that just about all of JS can be written in Arc, but would also gain the advantage of macros.

-----

3 points by nostrademons 6049 days ago | link

There was some reason I didn't do it that way (I'm the author of ArcLite). IIRC, it was because the semantics of Arc forms differed in a way that would basically require an Arc interpreter anyway, even if you compiled them. For example,

    (foo "bar" 1 2)
is only a function call if foo is a function object. If foo is an array, it's an array index; if it's a hash, it's a dictionary get (both ill-formed in this example). Other operations are similarly polymorphic, eg. overloading + for addition and concatenation. In order to translate that reliably to JavaScript, you'd need to turn every funcall form into a type-dispatch. At that point, you're basically writing an interpreter anyway.

-----

3 points by absz 6073 days ago | link | parent | on: Interesting macro 'focus

I like it! Though it'd probably be better to use an optional parameter rather than a variadic function for what you're focusing on:

  (mac focus (var . body)
    (w/uniq (storage unbound)
      `(withs (,storage nil
               ,var     (fn ((o arg ',unbound))
                          (if (is arg ',unbound)
                            ,storage
                            (= ,storage arg))))
         ,@body
         (when (is arg ',unbound)
           ,storage))))
(And you'll notice that since arg is lexical, you don't need to make it a gensym.)

-----

4 points by drcode 6073 days ago | link

Your definition has a typo, I think- What you probably meant is:

  (mac focus (var . body)
    (w/uniq (storage unbound)
      `(withs (,storage nil
               ,var (fn ((o arg ',unbound))
                      (if (is arg ',unbound)
                          ,storage
                          (= ,storage arg))))
         ,@body  
         ,storage)))

-----

1 point by drcode 6073 days ago | link

I thought about that, but then thought it would prevent you from returning 'nil... but your solution handles that case.

I agree your definition is better.

-----


Yes, but Arc (or at least Anarki) does not:

  arc> #hash((a . 1) (b . 2))
  Error: "Type: unknown type #f"
We can, however, read it in, but this doesn't work either, since it creates immutable hash tables:

  arc> (= h (read "#hash((a . 1) (b . 2))"))
  #hash((b . 2) (a . 1))
  arc> h!b
  2
  arc> (= h!b 3)
  Error: "hash-table-put!: expects type <mutable hash-table> as 1st argument,
  given: #hash((b . 2) (a . 1)); other arguments were: b 3"
Fixing these would probably be worthwhile.

-----

3 points by absz 6078 days ago | link | parent | on: Pipe operator

Here's an implementation of a >> function; you'd have to write

  (>> 8
      [expt _ 5]
      -
      [take-away _ 'monkeys]
      [prn _ "monkeys left"])
instead, though.

  (def >> (parm . args)
    (if (no args)
      parm
      (apply >> ((car args) parm) (cdr args))))

-----

2 points by almkglor 6078 days ago | link

Avoiding apply:

  (def >> (parm . args)
    ((afn (parm args)
       (if (no args)
           parm
           (self ((car args) parm) (cdr args))))
     parm args))

-----

4 points by rincewind 6078 days ago | link

Avoiding re-inventing rreduce:

  (def >> args
     (rreduce (fn (a b) a.b) rev.args))

-----

3 points by almkglor 6078 days ago | link

Avoiding rev:

  (def >> args
    ; throw an error here so that user won't get
    ; mysterious errors in the 'reduce part
    (if (no args)
      (err "'>> requires at least one argument"))
    (reduce (fn (a b) b.a) args))

-----

1 point by tokipin 6078 days ago | link

deeplier pat matched version:

  (def >> (val . (f . rest))
      (if rest
        (apply >> (f val) rest)
        (f val)))
one thing i noticed is that it's easy to lodge prn in for debugging:

  (>> 1
      [* 20 _] prn
      [* 2 _] prn
      [/ _ 8])

-----

2 points by absz 6092 days ago | link | parent | on: Install Arc on Eee PC?

If you are actually typing mzscheme-m-fas.scm (which is not what you wrote in your original comment), that's your problem: you need to write mzscheme -m -f as.scm . (If not, I don't know what to say.)

And a stylistic note: when replying to someone, click on the link to their comment and actually reply; it makes following the discussion more smooth :)

-----

2 points by TheDuke 6092 days ago | link

Turns out the error was even sillier: I had to switch to the arc2 directory and then execute mzscheme -m -f as.scm. (I was not lying when I told you I was new at this). Sorry for the stylistic annoyance. Thanks for your help!

-----

3 points by almkglor 6092 days ago | link

LOL. This is currently a weakness in Arc: it can only be run on the exact same directory as the arc2 installation. ^^

-----

1 point by absz 6093 days ago | link | parent | on: Ask The Community: Lexical Scoping

For what it's worth, (PLT) Scheme can in fact do what you require. After all, there's an implementation of defmacro that ships with it (though it might be called something else)! And there's a way (if I recall correctly, a very long, verbose way, shoring up your second reason) to implement aif and the like in their system by "requesting a shadower" or something like that.

-----

3 points by absz 6096 days ago | link | parent | on: Ask The Community: Lexical Scoping

The biggest reason Arc has unhygienic macros is that they are conceptually simpler in terms of implementation: the code that the macro outputs is spliced right in, with no preprocessing/wrapping/whatever. If macros were hygienic, they would have to be preprocessed somehow before being substituted in.

Whether this simplicity is better than hygiene is, as you have probably noticed, argued about, but that's the rationale.

-----

More