Arc Forumnew | comments | leaders | submit | CatDancer's commentslogin
1 point by CatDancer 6690 days ago | link | parent | on: Musings on Language Design

Very cool! I'll look into that. Ah, written by Audrey Tang, why am I not surprised :-)

I had been planning to call Perl in a subprocess, but this of course will be much more fun (if it works).

I'll be particularly wanting to know how it interacts with MzScheme threads...

-----

1 point by mst 6688 days ago | link

If you do have a go, mail me at mst -> shadowcat.co.uk, I know a bit about the perl side of things and my first CPAN release was fixups to Guile.pm so I'd be interested to help you.

-----


http://sisc-scheme.org/manual/html/ch05.html#SerialIO

-----

5 points by CatDancer 6692 days ago | link | parent | on: First Priority: Core Language

I wonder if an eager hacker might like to take a look at compiling Arc to ActionScript (maybe using something similar to http://www.omnigia.com/scheme/cpscm/home/ or http://www-sop.inria.fr/mimosa/personnel/Florian.Loitsch/sch... ?), so Arc could be driving a Flash application in the browser.

-----

1 point by kennytilton 6692 days ago | link

Given that we have a report of a JS Arc (ArcLite) and that ActionScript is supposed to be a JS... sounds like we're almost there. :)

-----

7 points by nostrademons 6692 days ago | link

The source itself is pretty close to ActionScript compatible. Problem is, I mess with the __proto__ property a lot for basic data types and for scope chaining. It's what lets me use JavaScript's native lookup mechanism for variable lookup; instead of searching down an a-list, I make each activation frame a JavaScript object and knit their prototypes together, so I can lookup variables with 'env[symbol]' and the whole search process is in C. __proto__ is a non-standard property; it's supported in all major browsers, but I wouldn't bet on it appearing in Flash. And I'm not sure it'd be fast enough if you had to implement variable lookup in the interpreter itself.

I thought about writing a compiler instead of an interpreter, but macros & quasiquote present a bit of a problem. You can compile the code down to JavaScript...but if you run into a quasiquote, you've got to jump back into the compiler to evaluate it, then splice that code back into your function, then eval the newly-generated JavaScript code to get back a real function. Remember, even ordinary functions like setforms (in the standard library) call macex at runtime, so you can't just separate things into a compile-time-only macroexpansion pass. And ActionScript doesn't have an eval function, so that gets a little complicated.

-----

3 points by CatDancer 6691 days ago | link

I understand your point about macros but not quasiquote... I thought `(a b ,x ,y c d) was an abbreviation for (list 'a 'b x y 'c 'd)? What am I missing?

I wonder if it might work if you have an identical Arc implementation in your compiler and in your runtime so that all the macro expansions can be done at compile time.

ActionScript3 flash.display.Loader.load() says it loads SWF files... does this include compiled ActionScript? If so, maybe a REPL inside the Flash application could be written by calling back to your server which ran the compiler. Not ideal, but certainly more fun than an edit -> compile -> run -> debug cycle.

-----

3 points by nostrademons 6691 days ago | link

`(a b ,x ,y c d) is an abbreviation for (quasiquote (a b (unquote x) (unquote y) c d). The quasiquote returns a literal list, except that whenever it encounters an unquote or unquote-splicing it hops back into the evaluator and evaluates the form in the local environment.

Flash load() is probably your best bet. My startup has a similar problem - dynamically generating code that will run in a browser - and we eventually decided it was easier to go with JavaScript/eval than Flash, even though we have to support Flash anyway for the finished product. Our other option was to send the code back to the server through Flash's XMLConnection, compile it there, returns a URL of the compiled SWF through the connection, then loadSWF() it and hope we can figure out how to dynamically reference the new classes. Check out MTASC for the server; Macromedia's Flash Compiler won't run on the command line.

Or you could just punt on the dynamic features. I don't support continuations in ArcLite, and I know someone doing a native-code port that's planning to leave out a few of the more dynamic features. Beware that I found (= ...) doesn't work if you leave out (macex ...), though.

-----

3 points by okplus 6692 days ago | link

ActionScript does have an eval function: http://www.adobe.com/support/flash/action_scripts/actionscri...

Edit: looks like it may be somewhat limited. Just names of variables. It doesn't actually eval beyond looking in the symbol table...

-----

2 points by nostrademons 6691 days ago | link

Yeah, it was a deliberate design decision by Macromedia. They wanted to keep the VM small, so they deliberately left out anything that smacked of a runtime compiler. Eval, regexps. Though I heard regexps may have come back in AS3...

-----

2 points by CatDancer 6692 days ago | link

I haven't yet heard of any Scheme -> JavaScript compilers that support eval (and thus a REPL)... so ArcLite (or some other interpreter written in JavaScript) would be a good way to support interactive programming in the meantime.

-----

3 points by olavk 6692 days ago | link

Writing flash apps in arc - that would be a _really_ cool showcase.

-----


  (def dl> (dl1 dl2)
    (let (y1 m1 d1 y2 m2 d2) (join dl1 dl2)
      (or (> y1 y2)
      . . .
"with" is a form of "let" that lets you make multiple assignments at once, so you wouldn't need the "join":

  (def dl> (dl1 dl2)
    (with ((y1 m1 d1) dl1 (y2 m2 d2) dl2)
      (or (> y1 y2)
      . . .
you'll notice the extra layer of parentheses, which is how "with" knows that you've stopped defining variables and have started the body.

-----

1 point by brett 6692 days ago | link

Thanks. I'm aware of with, I just thought I'd save some parens. Yours does read a bit easier.

-----

1 point by brett 6692 days ago | link

The other thing I'm noticing is that I've been nesting lets when the second assignment depends on the first. I think I should be using withs which I did not know about.

-----

2 points by CatDancer 6692 days ago | link | parent | on: nifty :

Not quite: you need tostring to capture the output of system (which is sent to stdout, not returned as a string). tostring is macro, so you can't compose it using :.

If I thought of a shorter name than "rmeol/ssystem" that I would still understand to mean "concatenate strings together, pass to system, capture the output, and remove the trailing newline", I would use it instead of "rmeol:ssystem". If "rmeol/ssystem" is the best I can come up with, then hey, I can save myself a function def and use "rmeol:ssystem". :-)

-----

2 points by CatDancer 6693 days ago | link | parent | on: Poll: What would you change in Arc?

Update: I see sjs is waaay ahead of me http://arclanguage.org/item?id=1430

I enjoyed using the Haskell Parsec library:

  http://legacy.cs.uu.nl/daan/download/parsec/parsec.html
It might be worth taking a look at for ideas, if you haven't seen it already.

Here's part of a JSON parser I wrote once:

  exponent_part =
    (string "e" <|> string "E")
    `followed_by` (string "+" <|> string "-")
    `followed_by` many1 digit
I wouldn't call it perfect... still too much work to keep Haskell happy, but certainly a lot nicer than using regexp's.

-----

2 points by partdavid 6692 days ago | link

I think "better string processing" is below the level of writing a grammar, even a mini-grammar.

If you treat strings as lists of characters and have good pattern-matching, this problem mostly solves itself, without something as ugly as regular expressions. You have the rich set of list operations, function-based predicates and, with clause selection by pattern, that's mostly what you need.

Yes, I know strings-as-lists seems like a terribly unoptimal thing to do; but it's an optimization challenge (how to optimize a particular backing representation of lists so that certain kinds of operations--subset matching, tokenizing, etc.--happen efficiently?), not something to bake into the language.

-----

4 points by CatDancer 6693 days ago | link | parent | on: Ask PG: And the canonical source is...?

Yes, exactly. The Git repository is terrific resource as a place to conveniently store everyone's patches, but of course some patches may be "bad" (by one criteria or another), and that is OK (good even) for its purpose.

I'm running Linux, and so date was broken and thus so was the web server, I looked in the repository and was happy to see someone had a fix, and I didn't even have to read the date man page (lazy me!)

So, just like you say, Paul's canonical releases of arcn.tar and a community repository (for good patches, bad patches, experimental patches, weird patches...) are both useful.

-----

1 point by bootload 6693 days ago | link

"... I'm running Linux, and so date was broken and thus so was the web server, I looked in the repository and was happy to see someone had a fix, and I didn't even have to read the date man page ..."

by git repos do you mean ~ http://git.nex-3.com/?p=arc.git;a=summary ? [0]

[0] http://arclanguage.org/item?id=809

-----

2 points by CatDancer 6692 days ago | link

Yes. When projectileboy said "the Git repo that's been created", I assumed he meant the one you just linked to (I don't know of any other), which is where I found the date fix.

-----

2 points by projectileboy 6691 days ago | link

Yep

-----

2 points by CatDancer 6695 days ago | link | parent | on: Arc Repo

Thank you! I was just starting to see if I could fix date on my Linux system when I thought, "hmm... I should go see if someone has fixed this already..." and there it was in your git repository! A fix by Nathan Weizenbaum! Yay!

-----