Arc Forumnew | comments | leaders | submit | aston's commentslogin
1 point by aston 5442 days ago | link | parent | on: Arc Logo

Here's the favicon I designed way back when this forum had an empty box in the corner. I still like it...

http://dl.getdropbox.com/u/165/arcfavicon.gif

-----

1 point by PebblesRox 5442 days ago | link

I think you should put parentheses around it :)

-----

5 points by aston 5891 days ago | link | parent | on: Is Hacker News code available?

It's in the latest arc package.

http://arclanguage.org/item?id=3426

-----

1 point by aston 5892 days ago | link | parent | on: Quick question - un-setting a symbol?

Might wanna have w/temps work more like

  (w/temps x y
    (def foo (x) (+ x y))
    (tempset y 10)
    (foo 5))
That is, like a with, but with x and y set to some dummy values. You wouldn't even need a tempset then, right?

-----

2 points by bogomipz 5892 days ago | link

Right indeed. The normal way to do this would be;

  (with (y nil foo nil)
    (= foo (fn (x) (+ x y)))
    (= y 10)
    (foo 5))
You can't use 'def there because, unlike in Scheme, def always makes a global binding in Arc. Including x in the with is not necessary, by the way.

From the sound of it, this does not solve lacker's problem, however, because he does not know up front what variables he needs to declare.

-----

2 points by aston 5905 days ago | link | parent | on: Keeping GET params in the case of a POST

That isn't actually too hard. You'll want to write your own defop__ dealie, but essentially you can just pull the vars you want out of the req variable. before calling the rest of the body.

-----

2 points by almkglor 5905 days ago | link

No, it is. Because the problem is that there's a whole bunch of defop_ dealies. defopr, defop-raw. Sure, you can make a macro-making macro, but I think it's better if we start from the top and define it in defop-raw, so that everything that builds on top of it uses (arg1 arg2) syntax.

Of course, there might be subtleties involved here anyway.

-----

8 points by aston 5905 days ago | link | parent | on: Keeping GET params in the case of a POST

Technically no. I read up on the spec a while back. GET parameters are probably better referred to as URL args, and they're always retrievable via the URL in the first line of the HTTP request. In the case of a POST, the content of the request may (also) have arguments.

It's not super common to use both, but it's definitely not disallowed by the spec.

-----

1 point by lojic 5905 days ago | link

I'd be interested in seeing any references about this. From what I've read, it seems the intent is to not combine them, but I haven't seen anything explicitly forbidding it. Do you have a source that indicates combining URL parameters in a POST is encouraged, or at least permitted?

http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13....

-----

4 points by aston 5905 days ago | link

I never claimed "encouraged." I just said nothing disallows it. Browsers all seem cool with it, so why shouldn't your web server be?

-----

1 point by lojic 5905 days ago | link

Well the OP stated:

"I noticed that in the case of POST handle-request-thread (srv.arc) throws away the GET args."

Which seems to be criticizing what I would consider perfectly valid behavior. I'm not sure why you would want to split your parameters for a POST between the POST parameters and pieces of the URL.

If a change to the source is being suggested, it seems reasonable to determine if it's warranted by the protocol.

-----

4 points by aston 5905 days ago | link | parent | on: ~Tilde and macros

But, unlike ~ and complement, no:litmatch works.

-----

8 points by pg 5905 days ago | link

no:litmatch only works in functional position, because (no:litmatch ...) is transformed in ac into (no (litmatch ...)).

To add to the confusion, it's a bug that ~litmatch doesn't work in functional position. There's a comment reminding me to fix that in ac.scm.

-----

1 point by parenthesis 5904 days ago | link

Wouldn't it make more sense for (~foo ...) to expand into (no (foo ...)) ?

-----

2 points by absz 5904 days ago | link

Not really, because that would make (keep ~foo lst) meaningless, and that's an important use of ~.

-----

2 points by cooldude127 5905 days ago | link

complement only works with functions. behind the scenes, it uses apply to call the original function. at first glance, i don't really see a reason that it couldn't just do the same as (compose no _)

-----

2 points by eds 5905 days ago | link

I know compose works on macros... but I'm not sure you are straight on, because compose uses apply as well. And the macro expansions look exactly the same.

  arc> (macex '(compose no litmatch))
  (fn gs1639 (no (apply litmatch gs1639)))
  arc> (macex '(complement litmatch))
  (fn gs1641 (no (apply litmatch gs1641)))
  arc> ((compose no litmatch) "a" "aston")
  nil
  arc> ((complement litmatch) "a" "aston")
  Error: "vector-ref: expects type <non-negative exact integer> as 2nd argument,
  given: \"a\"; other arguments were: #3(tagged mac #<procedure>)"
So what is going on here?

-----

3 points by cooldude127 5905 days ago | link

except calls to compose are optimized away in the interpreter. they are treated specially. look in the `ac' function in ac.scm. i'm guessing this is the reason.

-----

1 point by absz 5905 days ago | link

Ah! That must be the problem, yes. Good catch!

Now, what to do about the other case... there's still no reason it should bug out, it seems to me. Or rather, it should be implementable in such a way that it shouldn't.

-----

2 points by cooldude127 5905 days ago | link

mainly, we need an apply that works for macros. why would that not be possible, i wonder.

-----

5 points by pg 5905 days ago | link

What you're thinking of can be done, but only by calling eval explicitly. I.e. what you could do thus with or if it were a function:

  (apply or args)
you have to do thus with the real or, which is a macro:

  (eval (cons or args))
This is not surprising, because macros live in the world of expressions, not values.

-----

3 points by aston 5905 days ago | link

What you mean is, we need macros to be first class.

-----

1 point by absz 5905 days ago | link

Yes, we do. But if I recall (and I can't test, because the git "wiki" broke for later mzschemes again), apply does work for macros, except it evaluates all the arguments first, which breaks things like and. Someone should test that, though; as I noted, I can't.

EDIT: No, sorry. It doesn't work. My bad.

-----

4 points by nex3 5905 days ago | link

Just as a note, the wiki is fixed now.

-----

1 point by absz 5905 days ago | link

I saw, that's how I was able to test. Thank you for setting it up, by the way! And if you fixed it, thank you for that; if someone else did, thank them for that.

-----

3 points by nex3 5905 days ago | link

You're welcome :-). It would be wfarr who fixed this issue, though.

-----

1 point by cooldude127 5905 days ago | link

well, yeah. basically.

-----

1 point by absz 5905 days ago | link

Compose does something very similar behind the scenes as well, in fact. So there's no reason it should work either.

-----

2 points by aston 5912 days ago | link | parent | on: Favicon?

A rose by any other name...

-----

1 point by aston 5913 days ago | link | parent | on: Syntax for optional/keyword args

Hmm. Allowing keyword args is pretty un-Arc-ish (is there a term for this yet?) in my eyes. Lots of extra tokens to specify keywords when you could've just used positional arguments with some optional args at the end.

-----

10 points by bogomipz 5913 days ago | link

Keyword arguments definitely have their place. They fix a problem with having too many optional args. Example:

  (def foo (a b c (o d) (o e) (o f) (o g))
If you want to call foo with g but not the other optional args, you'd have to write

  (foo 1 2 3 nil nil nil 42)
It's easy to loose track of positional args when there are more than say 5 of them (depends on the person), and it gets a lot worse when some are just nils. The above call with keyword args instead of optionals would be something like;

  (foo 1 2 3 'g 42)
Or, depending on the implementation, there might be a special syntax;

  (foo 1 2 3 :g 42)

-----

3 points by aston 5913 days ago | link

I think there are two distinct cases here. The first is when a procedure is taking a number of options/switches. The second is when the function has a long list of optional arguments.

I actually think the second is pretty rare, especially if the argument list is ordered by practical use. The first is handled pretty nicely by passing in association lists or hash tables. Of course, the current syntax for creating hash tables doesn't make using them as arguments super-easy, but they're the equivalent of passing a dictionary in python for kwargs, and they don't require any new syntax.

edit: In my imagined world, your last example would look something like

  (foo 1 2 3 (table g 42))
where table could take kv's ad infinitum.

-----

2 points by bogomipz 5913 days ago | link

I don't see the distinction between taking a number of options and having a number of optional arguments. To me, this is exactly the same. A switch is an argument that is only checked for true/false, which means that in ordinary function calls you only really want to bother with it when passing 't.

It's true that passing a data structure can do most of the job of keyword arguments. Any searchable structure will do, really. Perhaps the simplest form from the call site's point of view is a property list. If Scheme's plist-get was implemented in Arc (trivial, but pg would probably pick a shorter name):

  (def foo (a b c . rest)
    (plist-get rest 'g))

  arc> (foo 1 2 3 'g 42)
  42
So, what do keyword arguments give you that tables/alists/plists do not?

1) better self documentation - the function signature tells what keys it understands

2) less code in the function body - you access the value like any other argument

3) a default form which is only evaluated if no value was given - without adding code to the function body

-----

1 point by sjs 5912 days ago | link

How about something like this:

  (def kw args
    (listtab (pair args)))
That makes it pretty easy to pass around kw args, and with a macro you could make it a little more sugary by allowing unquoted keys.

-----

4 points by aston 5914 days ago | link | parent | on: Meta Forum Questions

noprocrast mode is supposed to keep you from procrastinating by using the forum. It's probably not so useful here, but it's a carryover from news.yc.

If you turn it on, maxvisit is the maximum session length here. minaway is the minimum time away from the site before you can start a new session. The site'll catch you breaking the rules, but you can continue despite its warning not to.

-----

2 points by aston 5927 days ago | link | parent | on: Forum Request

The real question is, who'll be the first to add full-text indexing to Arc's hashtable implementation?

-----

More