Arc Forumnew | comments | leaders | submit | dfranke's commentslogin
2 points by dfranke 6121 days ago | link | parent | on: Monadic-like macro

This looks like perl's $_, but I don't see what it has to do with monads. What corresponds to >>= and return?

-----

1 point by vrk 6121 days ago | link

Definitely $_, although the initial value has to be defined here explicitly.

-----

2 points by applepie 6121 days ago | link

Now it behaves as Haskell's do-notation for the identity monad.

It could be adapted for other monads if it also took return and (>>=) as arguments.

  (mac w/ (monad x . rest)
    (w/uniq (gmonad)
      ((afn (x rest)
         (if (no rest)
           `(let ,gmonad ,monad ,x)
           (self `((car ,gmonad) (fn (_) ,(car rest)) ,x)
                 (cdr rest))))
       `((cdr ,gmonad) ,x))))

  (= list-ret list)
  (= list-bind mappend)

  (= list-monad (cons list-bind list-ret))

  (w/ list-monad 10
     (list (- _ 1) _ (+ _ 1))
     (list _ (* _ 2) (* _ 3)))

  ===>
  (9 18 27 10 20 30 11 22 33)

-----

1 point by dfranke 6127 days ago | link | parent | on: "Axioms" that might need to be added

  (= foo (- 10 ... 3))
  (foo 2 1) --> 4

  (def bar (x y) [+ x y 2 _])
  (bar 1 2 3) --> 8

-----

1 point by dfranke 6131 days ago | link | parent | on: How Arc should handle vectors

PG talks about his views on OO here: http://paulgraham.com/noop.html

But what does this have to do with vectors?

-----


On second thought, real vs. effective user isn't needed. You can simulate that by encapsulating a suid function inside a non-suid function that checks the current userid and passes it as an argument to the suid function.

-----


That's more the domain of a concurrency system than a security system, isn't it?

-----


You can implement this on top of my given axioms. My system isn't meant to be friendly; it's meant to be the simplest possible building blocks for a friendly system.

-----

3 points by dfranke 6132 days ago | link | parent | on: Nitpick: Why "rem" and not "rm"?

`rem' makes me think I'm looking at a comment. I spent far too much of my youth using DOS.

-----

2 points by partdavid 6132 days ago | link

I would think "remainder" or "remaining", while the "rm" command suggests removal to me.

-----

2 points by dfranke 6132 days ago | link | parent | on: How Arc should handle vectors

That's basically my point: there's no reason to clutter the language semantics with the distinction. The reason I'm discussing implementation is to show that it can still be handled efficiently.

-----

1 point by dfranke 6132 days ago | link | parent | on: core language thingies

What's wrong with

  (let d (+ a c)
     (if (> d b) (= a d)))

and if your concern is efficiency rather than readability, yell at your compiler guy to implement common subexpression elimination.

-----

2 points by bOR_ 6132 days ago | link

simplicity. I want (and I think I've seen enough examples of code now to write a macro to do so).. I want to be able to say / think / write this:

  (if (calculation gives wanted result) (assign calculation to variable)).
saying / thinking / writing your version just puts the language in the way of what I want to write down.. and even though the difference is minimal, all these little kind of things can add up and obfuscate your code.

  (store calculation as variable
    (if (variable gives wanted result) (assign calculation to another variable))
General idea of the post was just to try and find bits and pieces where the language can be smoothened.

-----

5 points by dfranke 6132 days ago | link | parent | on: How Arc should handle vectors

PHP's brokenness doesn't mean Arc has to imitate it. You'd get a vector up until the $a['another metasyntactic variable'] line, at which point it would turn into a hash table with two integer keys and one string key. Asking for $a[2] would always either return nil or throw an exception regardless of whether it was a hash table or a vector at the time.

-----

More