Arc Forumnew | comments | leaders | submitlogin
Poll: Destructive operations naming
7 points by stefano 6004 days ago | 14 comments
What do you think should be the standard naming in Arc for destructive operations?
The CL way: prepend a 'n' to the name, join -- njoin
2 points
The Scheme way: append a '!', join -- join!
18 points
The module way: put every destructive function in a module named 'd', join -- d!join or d@join or whatever -- please note that there is no standard module system yet.
2 points
Prepend a 'd', join -- djoin
1 point
Prepend a 'd-', join -- d-join
0 points
Append a '/d', join -- join/d
4 points


3 points by tiglionabbit 6002 days ago | link

The scheme way is also the ruby way, so it's probably the most conventional. I could see us using join/d though, as it looks kinda like the w/link method in the arc challenge, so we could be starting our own convention. Personally, I'd love to see a convention for predicates to end in '?', which would go along with the '!' convention quite well.

-----

4 points by bOR_ 6001 days ago | link

Except that the ruby way isn't consistent. ! is used to warn people that this method is destructive for sure. The lack of ! doesn't imply non-destructiveness.

That bit me before ;) http://www.ruby-forum.com/topic/135076#new

-----

2 points by almkglor 6002 days ago | link

The current Anarki ssyntaxes.arc defines foo? as [isa _ 'foo] :

  Arc2:
  (isa foo 'sym)

  Anarki w/ ssyntaxes.arc:
  (sym? foo)

-----

1 point by antiismist 6003 days ago | link

It is probably best to avoid any standard that involves non-alphanums, because that character could become a part of the syntax if pg feels like it one day.

-----

2 points by absz 6003 days ago | link

There's already one existing syntax for !, and I think it's unlikely that pg will add another. We're taking advantage of something which is, essentially, defined to be meaningless in arc2.tar but which we can make work on Anarki and using it. And of course, pg can do anything he wants, but that could involve both new ssyntax and new functions. We have been warned that what we're doing is "unsafe," after all. If we do avoid alphanumerics and choose, say, djoin, what happens if pg choose njoin for arc3.tar? Or uses the d prefix for something else? Using existing ssyntax characters is probably pretty safe.

As you might have guessed, by the way, I support the join! standard :)

-----

2 points by almkglor 6003 days ago | link

> If we do avoid alphanumerics and choose, say, djoin, what happens if pg choose njoin for arc3.tar? Or uses the d prefix for something else?

We say "I suggest running a poll on this, pg" ^^

But I still like module syntax T.T However the appended ! convention is winning by a really large margin (waaa hopeless!). So we need to modify the builtin ssyntax/ssexpand to ignore trailing "!" and/or standardize on my ssyntaxes.arc

-----

1 point by antiismist 6002 days ago | link

OK, another point. There is a virtue in having a standard that is backwards compatible with the base Arc release.

For example, I recently borrowed classifier.arc from anarki and ran it with the base release of arc with no troubles. If people start using the ! standard, then to use anarki libs one would have to run all of anarki. Which may be OK, it just has to be accepted that this is the case.

(As a matter of style I like ! too)

(somewhat related tangent:

[One of the best of these is a Gosperism. Once, when we were at a Chinese restaurant, Bill Gosper wanted to know whether someone would like to share with him a two-person-sized bowl of soup. His inquiry was: "Split-p soup?" -- GLS]

http://www.everything2.com/title/the%2520-P%2520convention )

-----

1 point by absz 6002 days ago | link

We're already not backwards compatible. Things like ssyntax.arc, for an extreme example, but also our additions of functions to places like arc.arc, e.g. butlast. That doesn't exist in arc2.tar, but we have it anyway. Anything that uses such functions requires Anarki. This is more extreme (you wouldn't be able to copy just those functions over), but not unique.

Nice story :)

-----

2 points by PieSquared 6004 days ago | link

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

-----

2 points by absz 6004 days ago | link

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

-----

2 points by eds 6003 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 6003 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 '?)

-----

2 points by rincewind 6004 days ago | link

what about d-join or join/d?

-----

2 points by stefano 6003 days ago | link

Added!

-----