Arc Forumnew | comments | leaders | submit | shiro's commentslogin

At this stage of language design, where everything is so fluid, there's little point to take such benchmarks, IMO. What you might want to look out is design flaws which make future optimization very difficult. (But considering the 100-year language goal, pg can argue that any optimization specialized to today's compiler and processor technology shall be premature optimization.)

-----


If you use succinctness as the only metric, I wonder how well J performs.

-----

7 points by shiro 6373 days ago | link | parent | on: Binary Search Trees in Arc

apply copies its argument list (guaranteed by Scheme spec). So this line lets the apply copy x, then passes it to a function that just returns the copied list. It may be faster than traversing the list in arc, for apply may be able to take advantage of underlying Scheme.

-----

2 points by akkartik 6373 days ago | link

Worth encapsulating in a macro perhaps?

  (copy x)

-----

1 point by lojic 6373 days ago | link

Cool - thx. Probably worth a small comment in the code.

-----

3 points by shiro 6374 days ago | link | parent | on: "Axioms" that might need to be added

One of my friend is a Haskell programmer and he and I once have tried to put implicit currying into Scheme.

The biggest problem is Scheme's variable arity. You might think you can do currying only based on the required arguments, but that doesn't work in practice. Suppose this simple "complement" procedure:

    (def complement (f) (fn args (no (apply f args))))
This loses arity information of original function f. It is extremely annoying that you get it curried for two-arg function f by

    (f 1)
and not curried for its complement:

    (~f 1)
Another example that breaks implicit currying is a simple debugging aid procedure that wraps the given function to trace its invocation. Just redefining f with the wrapped f (which, many simple 'trace' macro does), and implicit currying on f break. It's very fragile.

If you have access to the internal of the implementation, you may be able to extract arity information from the original function and transplant it to the new function. But automating it generally is difficult, and relying programmers to do that manually is cumbersome.

Our conclusion was that implicit currying and variable arity (without type information) didn't mix. You have to choose either one.

-----

1 point by binx 6374 days ago | link

The same statement can be used for multiple inheritance. Some people may call it a trouble maker, while some people call it a feature...

-----

3 points by shiro 6374 days ago | link

I don't quite get the parallel. I'm talking about introduction of a new feature X breaking a model implied by an existing feature Y, even if there's nothing wrong with either X or Y individually. Can you elaborate your remark?

-----


But isn't it possible that you have foo?bar as ssyntax and a lone ? for other purpose?

-----

1 point by nex3 6374 days ago | link

But what if he wants to conserve the lone ? as well?

-----

1 point by shiro 6374 days ago | link

Well we can only speculate. He said he wants to reserve '?' for ssyntax, and I pointed out '?' in ssyntax and lone '?' can coexist. If he also reserve lone '?', that's his decision.

-----


If one stroke of shift is so important, you should ditch () and use [] to represent the primary list structure :-)

(Or you would use Symbolics keyboard which you can type () without shifting.)

-----

2 points by vrk 6375 days ago | link

As a sidenote, square brackets are harder to type on Finnish/Swedish keyboards than ordinary parenthesis. The former requires Alt Gr + {8,9}, the latter Shift + {8,9).

(Why am I using the Finnish keyboard layout to edit code? A bad habit from the past, admittedly.)

-----

1 point by helium 6374 days ago | link

same in germany

-----

2 points by tokipin 6375 days ago | link

programmer dvorak: http://www.kaufmann.no/roland/dvorak/

been using it for about a year and dvorak in general for three or four. the difference in comfort vs qwerty is huge

-----

2 points by sacado 6375 days ago | link

or a french keyboard

-----

2 points by shiro 6375 days ago | link

good for french lispers! you can save 5-10% of typing!

-----

3 points by shiro 6376 days ago | link | parent | on: Ruby-like in place list expansion

To build a list, you can already use quasiquote---a standard idiom in Lisp-family languages.

    (let insetion (if (is-new) (list "new") nil)
       `("hello" "brave" ,@insertion "world"))
What matters is to expand a given list into an argument list. To do that you have to use 'apply' now.

-----

2 points by shiro 6377 days ago | link | parent | on: Ruby-like in place list expansion

That's a tempting idea; the problem is that you can only use a single variable after the dot. Because of the very definition of S-expression,

    (+ . (f x y))
is indistinguishable from

    (+ f x y)
However, just allowing single-variable case may be good to cover typical cases.

-----

3 points by shiro 6378 days ago | link | parent | on: Parallel programming in Arc

check out atomic-invoke. also search atomic in arc.arc.

-----

1 point by almkglor 6377 days ago | link

So... that's it? atomic? If so, does the fact that (= ...) are done (atomic ...) mean that I can just, well, write to a variable and automatically expect locking?

-----

2 points by shiro 6377 days ago | link

For the first question: Yes, to me it appears atomic-invoke is the locking primitive and everything else is built on top of it.

For the second question: note that (= ...) only expands to atwith when the generalzed location appears in the place to be set. The simple assignment

    (= a (f x) b (f y))
isn't protected. (That is, some thread may see a state where a is updated but b isn't yet, for example).

    (++ a)
is also unsafe if a is shared between threads, since it expands to

    ((fn () (set a (+ a 1))))
OTOH,

    (++ (car a))
becomes

    (atomic-invoke 
      (fn nil (withs (gs1430 a gs1429 1) 
                ((fn (val) (scar gs1430 val)) 
                 (+ (car gs1430) gs1429)))))
so it seems safe.

-----


e) In R5RS Scheme you have to specify the global environment where the expression is eval'ed, but it only specify three envirionments, two of which are very restricted. So, using (interaction-environment) is the easiest way to get the behavior of legacy 'eval'. Various implementations extend this part of semantics, but you'll lose portability. Cf. http://practical-scheme.net/wiliki/schemexref.cgi?eval

-----

More