Arc Forumnew | comments | leaders | submitlogin
1 point by dpkendal 4956 days ago | link | parent

The first one is clearly in issue. I propose also to replace reduce with this (happily, tail-recursive) version:

    (def reduce (f xs)
      ((rfn rdc (a s)
        (if (no s)
          a
          (rdc (f a (car s)) (cdr s)))) (car xs) (cdr xs)))
which avoids this problem by returning nil when `xs` is nil.

However, I would consider the second issue to be merely incidental. It is still a correct result.



2 points by thaddeus 4956 days ago | link

I wouldn't assume something is incidental unless the purpose has been researched. And, I believe, its correctness can only be determined by its intended use... Which is why I was kinda suggesting someone check where and why it's actually used.

As a guess, 'best' is probably used for http://arclanguage.org/best in the news.arc code. In which case it's probably not an issue... ?

At any rate, references should probably be checked? Or maybe, instead, news.arc code should be dropped from anarki? Could it be that supporting news.arc only stifles arc's development?

-----

2 points by rocketnia 4956 days ago | link

I think supporting anything stifles development. It's a contradiction I just try to accept. :-p

I don't see the purpose of 'best. I don't see a bigger purpose in most of Arc. If what Arc gives me isn't what I need, I reinvent it.

(In fact, I think if we try to keep working on the same language, rather than tearing it down and reinventing it, we're worrying about at least some kind of "support" and stifling our development. But too much tearing down can be destructive too, of course. :-p I appreciate that you're applying a scientific-ish mindset to this.)

There are a few ways to cut through this Arc ennui:

- If Arc gives me tools I can use to reinvent things, those tools are extra-relevant, since even if I don't like them I'll use them on my way to replacing them. This is not something 'best does for me.

- Sometimes we may want everyone in the language community to use the same variant of something, so that the tools we build around that thing can work together. Are we trying to optimize 'best in the compiler/runtime? Nope. Do people often extend 'best with extra capabilities? Nope. Even if these things were true, are we even having an issue with people reinventing 'best all the time? Nope, I don't think so.

- Do I still kinda like to discuss it? Yep. :-p

-----

3 points by thaddeus 4956 days ago | link

I agree with everything you're saying... and, also, in thinking about it further, I believe that having namespaces as a first class feature is the best way to solve this kinda problem.

For example, in Clojure, I can just build my project by excluding the function in question and replace it with my version. Anyone else that wants to use Clojure doesn't need to worry about another persons great idea.

; example

  (ns a-project.core
    (:refer-clojure :exclude (best))
    (:gen-class))
  
  (defn best []
    ...)
And anyone else wanting to use my library and/or only use my version can do so, simply:

  (ns your-project.core
    (:refer-clojure :exclude (best))
    (:use [a-project :only (best)])
    (:gen-class))
   
   (defn do-my-stuff []
    (best ....))
And I can't even remember now - did anarki get namespaces? I know there were some implementations, I just don't know if it made its way into anarki.

I also believe namespaces would promote the sharing of libraries, which arc also suffers from.

-----

1 point by rocketnia 4956 days ago | link

I think it's cleaner to define 'reduce in terms of 'foldl:

  (def reduce (func xs)
    (whenlet (x . xs) xs
      (foldl func x xs)))
But I don't even really want 'reduce. If the function is '+, an empty list should give 0. If the function is '*, an empty list should give 1. Instead of trying to divine this value from nowhere, I think it makes more sense to pass the base case manually, as with 'foldl.

Alternatively we could have this...

  (def reduce (func xs)
    (iflet (x . xs) xs
      (foldl func x xs)
      (func)))
...but if the function is set up to take different numbers of arguments, we probably should have done (apply func xs) in the first place.

-----