Arc Forumnew | comments | leaders | submit | t1m's commentslogin
2 points by t1m 6165 days ago | link | parent | on: Symbols ending in *

Ok thanks. Is it just a naming convention, or does anything magic happen?

-----

4 points by kennytilton 6164 days ago | link

Just a naming convention, but it is such an insanely easy convention to follow and recognize that what could be an absolute nightmare (dynamic binding outside the lexical scope being unwittingly shadowed and broken by an innocent choice of variable name) simply never happens. Almost like magic. :)

-----

1 point by t1m 6165 days ago | link | parent | on: macro / function question

Does this work...

  (mac twodimlist (x y)
    `((twodimlist ,x) ,y))

?

-----

1 point by kennytilton 6164 days ago | link

I see you have corrected the above by switching to a different name (a reasonable way to go) but it might be fun to see if you can stick with one and expand differently based on whether one or more than one value is supplied (meaning of course you need to support what we call &rest in CL in the parameter list of twodimlist. What I do not know is how well Arc likes to expand a macro into code referencing the same macro.

-----

1 point by t1m 6165 days ago | link

Oops, ignore the above. How about this...

  arc> (mac blah (n x y) `((,n ,x) ,y))
  #3(tagged mac #<procedure>)
  arc> (macex1 '(blah twodimlist 0 3))
  ((twodimlist 0) 3)

?

-----

2 points by sjs 6163 days ago | link

Arbitrary number of arguments:

  (mac drill (lst . xs)
    (if (no xs)       `,lst
        (no (cdr xs)) `(,lst ,(car xs))
        `((drill ,lst ,@(rev (cdr (rev xs)))) ,(last xs))))

-----

1 point by t1m 6166 days ago | link | parent | on: Packages/modules/namespaces/classes/units

Erlang has modules. It's ability to allow user defined loading mechanisms for them is a nice feature:

http://www.erlang.org/doc/man/erl_prim_loader.html

-----

2 points by partdavid 6166 days ago | link

Maybe arc could also provide online code upgrades as well.

I like the idea of qualified names (namespaces for things) but prefer it to be divorced from the name of the resource where you find it. For example, in Perl and ruby I can require 'coolstrings.rb' which doesn't have anything to do with a "coolstrings" namespace or class but does change the way strings behave. It also provides a way to elegantly implement pragmas.

-----

1 point by ryantmulligan 6165 days ago | link

Live code upgrades is a great feature. Lisps already support this to some degree. If you make an app and expose a REPL on some local port then you can recompile functions on the fly. I'm not sure how it handles the current execution stack when this happens though.

-----

2 points by t1m 6168 days ago | link | parent | on: install

http://www.automatthew.com/2008/01/installing-arc-on-mac-os-...

-----

2 points by billn 6168 days ago | link

Thanks!

-----


<?php

  session_start();
  
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $_SESSION['said'] = $_POST['said'];
    echo '<a href="">click here</a>';
  } else {
    if (isset($_SESSION['said'])) {
      echo 'You said: ' . $_SESSION['said'];
      unset($_SESSION['said']);
    } else {
      echo '<form method="post">';
      echo '<input type="text" name="said">';
      echo '<input type="submit">';
      echo '</form>';
    }
  }
  
?>

-----

2 points by namaste 6170 days ago | link

Here's the same thing translated into Ruby + custom Web Framework + Tenjin:

<?rb

  if @w.req.post?
    @w.session['said'] = @w.f('said')
    @w << '<a href="">click here</a>'
  else
    if @w.session['said']
      @w << "You said: #{@w.session['said']}"
      @w.session.unset 'said'
    else
      @w << '<form method="post">'
      @w << '<input type="text" name="said">'
      @w << '<input type="submit">'
      @w << '</form>'
    end
  end

?>

BTW, your example made me spot a bug and fix it and also add the "unset" method to the Session class. Cool enough. Thanks! :-)

-----


"Any sufficiently advanced technology is indistinguishable from magic."

http://en.wikipedia.org/wiki/Arthur_C._Clarke#Quotes

-----