Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 5034 days ago | link | parent

So if I read you right, you're saying that having intersperse do something special for lists of strings is ok, and we could include a longer-named version that doesn't do the specialcase?


1 point by aw 5034 days ago | link

Yeah. I think so. For example, "map" returns a string when passed a string, which strikes me as a similar situation.

I could see having a longer-named version of "map" which is the primitive, simple case, that just returns a list. So if I know I want a list I have the option of calling the longer named version, while the shorter named versions such as "map" or "intersperse" do whatever is the most common case of what I usually want.

-----

1 point by akkartik 5033 days ago | link

Makes sense, thanks for the map example.

I think I was confused because intersperse doesn't seem like a short name to me :) But of course you mean 'prime namespace real estate', which is partly about length but also about being an english word and so easier to remember.[1]

intersperse still seems weirder than map, because map just returns the type of its args, while intersperse is checking the type of elements inside its list arg.

[1] This made me also focus on the fact that testify is actually an english word - and arc is misusing it.

-----

2 points by rocketnia 5033 days ago | link

intersperse still seems weirder than map , because map just returns the type of its args, while intersperse is checking the type of elements inside its list arg.

Yeah, that's one reason I'm not sure I agree with this proposal. Fundamentally, I don't like the idea that (intersperse x (list a b c)) would return (list a x b x c) sometimes and (+ a x b x c) others.

If "string:intersperse" is common enough to be a standalone utility with a shorter name, I'd probably name it after PHP's implode(). I'd probably make it use '+ too, so that it could be used to construct lists and custom types of sequence:

  (def implode (first between seq)
    (apply + first (intersperse between seq)))
  
  (implode "?" '& ...)
  (implode "" "\n" ...)
Using '+ instead of hardcoding 'string makes less sense if you have '+ dispatch on the type of the last argument. But hey, I'm a fan of dispatching on the first arg anyway. ;)

This made me also focus on the fact that testify is actually an english word - and arc is misusing it.

How about 'checkify? ^_^ I don't actually mind word misuse, but I do kinda like the idea of reserving the term "test" for unit tests, and I suppose there are even contexts where 'testify could be used for its English meaning:

  - assertions
  - debugger interaction
  - proofs
  - simulations of belief, knowledge, perception, persuasion, etc.
  - generally, status reports, contracts, and sanity checks registered
      with some surrounding framework or compiler

-----

1 point by akkartik 5033 days ago | link

Oh I like implode, thanks. Especially if it's used in this sense in another language, that makes it closer to 'prime real estate'.

-----