Arc Forumnew | comments | leaders | submit | randallsquared's commentslogin
3 points by randallsquared 6315 days ago | link | parent | on: We Have Docstrings

While "doc" is more historical, it would also be a nice, short name for a variable containing a document.

Of course, presumably most people using a help or docstring function would be doing so at a prompt, where they're not inside a let...

-----

3 points by randallsquared 6316 days ago | link | parent | on: Continuations?

They're in there. What you want is called ccc. Note that the tutorial is not the spec; arc.arc is the spec, and ccc is used, at least, in that. :)

-----

1 point by saharrison 6314 days ago | link

Okay, thanks. Good point about the tutorial - that's what I get for being lazy. ;-)

-----


The symbol 'if is a special operator, not a macro or function. The special operators in Arc's compiler are quote, quasiquote, if, fn, and set.

Probably it would be convenient to have an object tagged as a special operator for those, but it would be documentation, not functional code.

-----

4 points by pg 6316 days ago | link

Special operator is what they're called in CL. I don't know offhand what they're called in Scheme. But what it amounts to is that if only exists as a clause in the compiler.

-----

2 points by randallsquared 6315 days ago | link

"Special operator is what they're called in CL."

Yeah, I know much less about Scheme than CL, so I used the CL term.

-----

1 point by jimbokun 6312 days ago | link

What are they called in Arc? :)

-----

2 points by pg 6312 days ago | link

Special operator sounds good. Or axiom, if we want to be fancy.

-----


I like the idea of symbols as a special case of strings, but I'm not as sure of the details. In particular,

    In a double-quoted string, you will have to escape parens, double-quotes and single-quotes by prepending a single-quote.
seems like a bad idea to me. Perhaps I don't understand why a double-quoted string wouldn't already be satisfactorily quoted?

-----

1 point by are 6316 days ago | link

Thanks; you're probably right that this is unnecessary, and wouldn't help the Arc parser much anyway.

You would have to escape double-quotes, though.

I like how Smalltalk handles this by allowing both single- and double-quotes as string delimiters:

"This is a string which includes two 'single quote' characters, which aren't escaped"

'This is a string which includes two "double quote" characters, which aren't escaped either'

This wouldn't work for Arc, though, if you also want to be able to use a _single_ single-quote for quoting symbols.

I've removed the sentence you quoted from my proposal.

-----

2 points by ehird 6316 days ago | link

wrong

smalltalk "abc"= comment

-----


Producing the kind of sequence it was given is not what I'd call broken. Additionally, your

    (map [coerce _ 'int] "foo")
    => '(102 111 111)
canonicalizes what I believe is an onion: strings that are transparently byte vectors.

-----

4 points by randallsquared 6316 days ago | link | parent | on: Technical Comments on Arc

Arc does have protect, but I'll leave it to more experienced lispers to tell us if it interacts well with ccc.

It seems to me that format and loop are two of the top 5 worst things about CL, and I can't see any reason why even those who like them would need them in the base language.

-----

2 points by randallsquared 6316 days ago | link | parent | on: Self referencing lambda

Ah, so rfn is short for 'recursive fn'.

-----

2 points by kennytilton 6316 days ago | link

Looks that way. :) This is why I think arc.arc should look like: (mac rfn yadda yada "Recursive FN: an anonymous function that can call itself" ...implementation...) FYI, CL is funny, both flet and labels elt us give names to loacl functions, but only those declared with labels can be called recursively. I wonder why flet got kept, backwards compatibility?

-----

2 points by randallsquared 6316 days ago | link

Well, as you know, there's a LOT of that in CL. CL is the PHP of lisps. :)

-----


The way I do PHP, there'd be two templates, a.html and c.html (for example), and a separate page b.html. Then, a.php would have

    <?php
    require_once('liball.php');
    
    if ($foo = $_POST['foo']) {
      $_SESSION['foo'] = $foo;
      localredirect('b.html');
    }
    sendpage('a');
    ?>
The template a.html has the form, and b.html just has the link on it.

Assuming page c needs to be protected against people just coming to it:

    <?php
    require_once('liball.php');
    if (!($foo = $_SESSION['foo'])) {
      localredirect('a.php');
    }
    sset('foo', $foo);
      
    
    sendpage('c');
    ?>
and the c.html template has in it

    you said: {$foo}
The only parts of this that aren't standard in PHP are the sset() and sendpage() calls, which are short for some longer stuff involving a template object, and the localredirect(), which just does some bookkeeping.

This is a lot longer than the Arc example, of course. However, one advantage it has (which is a must for some of us) is that once I'm done writing it, I can hand the html files to a web designer and I don't have to do anything at all when the boss/client wants to completely change the way it looks.

-----

8 points by randallsquared 6316 days ago | link

Perhaps a more traditional PHP version is:

    <?php
    // unvarying HTML elided above
    if ($foo = $_POST['foo']) {
      $_SESSION['foo'] = $foo;
      print '<a href="">click here</a>';
    } else if ($foo = $_SESSION['foo']) {
      print 'you said: ' . $foo;
    } else {
      print "<form method='post'><input type='text' name='foo'><input type='submit'></form>";
    }
    ?>

-----

1 point by bonzinip 6310 days ago | link

More complicated, but scales better to more complex problems and it is back-button friendly.

    <?php
      $step = isset ($_POST['step']) ? $_POST['step'] : 0;
      if ($step == 0)
        $_POST = array();

      $_POST['step'] = ($step + 1) % 3;
      echo '<form method="post">';
      foreach ($_POST as $k => $v)
        echo '<input type="hidden" name="' . htmlspecialchars ($k) . '"
            value="' . htmlspecialchars (stripslashes ($v)) . '" />';
    
      echo '<p>';
      switch ($step)
        {
        case 0:
          echo '<input type="text" name="simon-sez">';
          break;
        case 1:
          echo 'Simon sez...';
          break;
        case 2:
          echo htmlspecialchars (stripslashes ($_POST['simon-sez']));
          break;
        }
      echo '</p>';
      echo '<input type="submit" value="Go on" />';
      echo '</form>';
    ?>

-----

1 point by rekall 6193 days ago | link

thank you for reaffirming my faith in php.

-----


I would suggest that marking a literal vector of bytes is not the most useful role double quotes could play. Python has a lot of history of using that, due to exactly this kind of confusion of strings and vectors of bytes, leading to b"", u"", etc.

-----

3 points by randallsquared 6317 days ago | link | parent | on: How to define f with 0 args?

    (def myfn ()
      ...)

-----

More