Arc Forumnew | comments | leaders | submit | PieSquared's commentslogin
2 points by PieSquared 6001 days ago | link | parent | on: Poll: Destructive operations naming

Isn't the Scheme way going to cause syntax problems? Or are we assuming that these are somehow avoided?

-----

2 points by absz 6000 days ago | link

See http://arclanguage.org/item?id=7595 — we can make it work already.

-----

2 points by eds 5999 days ago | link

Really? What if you want to use destructive-named functions with the current meaning of '.', '!' and ':'? E.g.

  (join.a.b)
Assuming s/join/join!/ this becomes:

  (join!.a.b)
And thus the destructive-named '!' isn't at the end of the string anymore, is it? Or do you have something else in mind?

-----

1 point by almkglor 5999 days ago | link

  (require "ssyntaxes.arc")
  (def foo! (x)
    (= (car x) 42))
  (= hmm '(3))
  foo!.x
Well, it has to do with the ssyntaxes.arc precedence rules and how they work: basically, split according to the current ssyntax, then go to next ssyntax. Since #\. is listed before #\!, symbols are first split by #\. into (foo! x), so it works properly.

It won't work with a type that ends in ! and if you use the ? ssyntax:

  (def my-type! (x)
    (annotate 'my-type! x))
  (my-type!? my-type!.1) ; will transform to (my-type '?)

-----

1 point by PieSquared 6028 days ago | link | parent | on: ([+ _ 10]:[* _ 20] 10) = error...

An unrelated question about the ':' syntax: does it really compose functions, or does it work with macros as well?

In other words, can I say

  (macro:function arguments)
or does it only work with functions?

-----

2 points by absz 6021 days ago | link

It's actually in-between:

  (f:g a b c)
becomes

  ((compose f g) a b c)
, which normally wouldn't work if f or g were a macro; however, compose is special-cased in ac.scm so that in the head of a list, this becomes

  (f (g a b c))
. Thus, : only works with macros at the head of a list. You can't do

  (f a b macro:function c)

.

-----

1 point by tokipin 6027 days ago | link

it works with macros as well, which makes for a convenient "modifier" syntax

example: http://arclanguage.com/item?id=4436

-----

1 point by almkglor 6027 days ago | link

The "ultimate" modifier being p-m:

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

-----

4 points by PieSquared 6031 days ago | link | parent | on: Lisp-style function definitions

I think it's just because many people are used to having the arguments declared separately from the name, since most other languages (including non-Lisps) do that as well.

-----

3 points by tokipin 6031 days ago | link

remember also that Arc autodestructurizes arguments based on the parameter list (example: http://arclanguage.org/item?id=6125.) scheme-style def would would conceptually interfere with that

though maybe scheme autodestructurizes like that also? i don't know

-----

1 point by conanite 6031 days ago | link

arc lets us write

  (def foo args ...

  (def foo (x y . rest) ...
so that args is the list of all arguments, and rest is the list of all arguments after the first two. I suppose the equivalent scheme-ish way would be

  (def (foo . args) ...

  (def (foo x y . args) ...
I like the fact that arc has no special &rest keyword, that rest args just fall out of the way lists are constructed.

I haven't used scheme so I'm not qualified to comment (but obviously that's not stopping me), but to this n00b it makes sense that the parameter list is distinct from the function name. And as you mention it makes named functions look more similar to anonymous functions. So I have less thinking to do when I'm looking at a parameter list.

-----

2 points by PieSquared 6046 days ago | link | parent | on: Ask AL: pprint + vim

Not the first time: http://arclanguage.org/item?id=6889

Congrats to him on becoming mini-leader of Arc!

-----

3 points by PieSquared 6096 days ago | link | parent | on: Implementation Question: Macros?

This is what I originally had in mind. As far as I can tell, this doesn't work for bytecode-compiled Lisp, correct? (Since it would compile it as a function call, although it's a macro...) So does that mean every implementation of Lisp has to have a single-pass interpreter in it?

-----

2 points by cchooper 6096 days ago | link

Well, every implementation of Lisp does indeed contain an interpreter: eval!

But the way Lisp compilers deal with recursive macros is to not allow them. From the Common Lisp spec:

"All macro and symbol macro calls appearing in the source code being compiled are expanded at compile time in such a way that they will not be expanded again at run time."

That rules out recursive macros. I think they're allowed when Lisp is being interpreted, but you should probably just not use them.

http://www.lisp.org/HyperSpec/Body/sec_3-2-2-2.html

-----


Question: Could this, perhaps, be solved by making the variable and function namespaces the same?

(I'm probably misusing terminology here, but what I mean is that you can't have a function and a variable named the same yet still stand for different things when used in code)

-----

2 points by cooldude127 6148 days ago | link

actually, arc does use the same namespace, that is most of the cause of this problem. if they were in different namespaces, there would be no problem with variables shadowing built-in functions. you still have to worry about variable capture, but it's a much less significant problem.

note: i'm not saying i don't like the same namespace thing. it actually shortens a great deal of code, and eliminates CL's stupid ass #' garbage.

-----