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

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

  Arc2:
  (isa foo 'sym)

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

-----

1 point by almkglor 6326 days ago | link | parent | on: Poll: Destructive operations naming

  (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 almkglor 6326 days ago | link | parent | on: Poll: Destructive operations naming

> 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

-----

4 points by almkglor 6329 days ago | link | parent | on: New Syntax Feature- Dangling Dot

Or by using ssyntaxes.arc on Anarki:

  (require "ssyntaxes.arc")
  (add-ssyntax-bottom
    #\. (L))

-----

2 points by almkglor 6329 days ago | link | parent | on: Poor Man's Regular Expressions

On Anarki there's the 're function which matches regular expressions. It uses the underlying mzscheme's regular expressions.

Also, we do have a decent parser library, treeparse: it's just not a very concise one. And I should really, really finish the treeparse tutorial I started.

-----

2 points by drcode 6329 days ago | link

thanks for the info- in that case, these functions aren't so useful (at least for anarki users)

-----

1 point by almkglor 6329 days ago | link | parent | on: Destructive list operations

my suggestion: D!join

-----

1 point by stefano 6329 days ago | link

This would mean to have a huge hash table containing all destructive operations, and that a lookup in that table would be necessary just to call a function. A namespace system (such that of CL) would be the right thing, because names in such a system are resolved before runtime.

(d::join ...)

The character #\: has been already taken, though. Maybe a good name would be (d/join ...). What do you think?

-----

1 point by almkglor 6328 days ago | link

Depends. If we accept the modification in http://arclanguage.com/item?id=7451 , it would be possible to make modules into a macro, and D!join would be resolved during macro-expansion into a 'uniq that can be 'symeval -ed to the destructive join operation.

-----

1 point by absz 6329 days ago | link

/ would be problematic, though, as we already have things like w/uniq, w/stdin, /, etc. I like Scheme's convention, so what about

  (add-ssyntax-bottom ; Or perhaps -top
    #\! (sym:string 'L #\!))
? This would allow us to use !s in the final position of a function name, e.g. join!.

-----

1 point by almkglor 6328 days ago | link

This makes:

  (join! foo bar)
into:

  ((sym:string 'join #\!) foo bar)
which doesn't seem to be what you want.

As an aside, you might want to try this on Anarki:

  (require "ssyntaxes.arc")
  (def foo! (x)
    (= (cdr x) 42)
    x)
  (= bar '(1 2))
  (foo! bar)

-----

1 point by absz 6328 days ago | link

That's what I would have thought, but it appeared to work. Though it may only have worked because of your second observation. And given that, I will repeat my desire for the destructive! custom. I like it because it doesn't interfere with any name (e.g. how alist could be association list or the "is the object a list?" predicate [though that's a bad example, you get the idea]), it has seen use in multiple languages, and it pretty clearly says what it means (assuming you want to encourage functional programming, as I think we do).

-----

2 points by almkglor 6328 days ago | link

I suggest running a poll on this - of course, pg probably won't care either way, but we can integrate his code into Anarki next time he bothers to release an update, ne?

I think this convention is good; I'm just somewhat concerned with the fact that foo!bar is plenty overloaded.

edit: IIRC this has been suggested a few times before already, so I think there'll be good support for this - but it means we will then have to formally standardize the ssyntaxes too.

-----

2 points by stefano 6328 days ago | link

Poll added :)

-----


maybe something related to http://decenturl.com/ might help: http://www.reddit.com/r/programming/info/5zcbl/comments/

Edit: It might be useful to add an optional parameter in some of the link-creating stuff where the programmer can add some sort of "hint" which the base system will use, so instead of http://example.com/a?fn=fkg34lk you get http://example.com/a?fn=voteup_fkg34lk

Or possibly just "make it long" and just have the base system add a number if the id clashes: http://example.com/a?fn=voteup-maybe-something-related-to-3

So yes: closure links per se don't prevent decent url's, naive implementations of closure links do.

-----

1 point by almkglor 6330 days ago | link | parent | on: Destructive list operations

None yet. tokipin's idea here is approximately what I had in mind for SNAP, where I might possibly define a module system accessible using module!export syntax, but really the problem is the interaction between modules and types as well as modules and macros.

-----

2 points by almkglor 6331 days ago | link | parent | on: A native Arc compiler for Linux

How'd you implement macros?

-----

1 point by stefano 6331 days ago | link

I've implemented them as I've described here: http://arclanguage.org/item?id=7097

They still have some problems when you use the compiler to compile itself, because macros have to run in the host compiler environment and not in the target environment (that doen't still exist). I'll write more about this problem in a NOTES file I have to add to the repository. The key point in implementing macros in a compiled system is first to get the system able to compile itself: once that point is reached, they are quite straightforward to implement, except for the problem mentioned before. The last two functions in transformations.arc plus the function eval in lib.arc implement macros.

-----


An alternative is to use the "lib/settable-fn.arc" or "lib/settable-fn2.arc" frameworks for this.

When using settable-fn.arc:

  (def create-my-type ()
    (add-attachments
      'key (fn () (generate-keys))
               ; note the order: value before key(s)
      '=   (fn (v k)  (assign-value-v-to-key-k v k))
      (annotate 'my-type
        (fn (k)
          (lookup-in-k k)))))
lib/settable-fn2.arc:

  (def create-my-type ()
    (add-attachments
      'key (fn () (generate-keys))
      '=   (fn (v k)  (assign-value-v-to-key-k v k))
      'type 'my-type
      (fn (k)
        (lookup-in-k k))))
Aside from 'keys and '=, it allows you to overload 'len

-----

2 points by almkglor 6332 days ago | link

The "Create your own collection" series should help a bit - these collections all use lib/settable-fn.arc, and with minimal modification should be useable with lib/settable-fn2.arc

http://arclanguage.com/item?id=3595 Suggest PG: Settable function objects

http://arclanguage.com/item?id=3698 Create your own collection in Arc: settable functions now implemented on arc-wiki.git

http://arclanguage.com/item?id=3762 Create your own collection: use directories as if they were tables with file-table

http://arclanguage.com/item?id=3858 Create your own collection: bidirectional tables

http://arclanguage.com/item?id=5254 Create your own collection: cached-table

http://arclanguage.com/item?id=7365 Create your own collection: proto-table, when you want prototyping semantics in your object system

-----

More