Arc Forumnew | comments | leaders | submit | Jekyll's commentslogin
2 points by Jekyll 6078 days ago | link | parent | on: Map et al arguments are backwards

  (def $ (x . lists)
         (if lists
             (apply map x lists)
             (fn (lists) (apply map x lists)))) 
More or less does what you want, without special syntax. ($$car... would have to be written ($($ car)... though.

To me this looks like a specific case of wanting currying/partial application built in for functions of semi-fixed arity, rather than a need for new syntax.

-----

2 points by absz 6078 days ago | link

You can even be cleaner: $car is $.car (though this doesn't work for $.$.car). But I don't think this is really a specific case of partial application (though I see where you're coming from). While partial application would be ((map car) '((1 2) (3 4) (5 6))) and this would be ($car '((1 2) (3 4) (5 6))), the biggest win (for me) is not the partial application aspect, but the conciseness of having just one character, as opposed to (currently) ([map car _] '((1 2) (3 4) (5 6))) or ([apply map car __] '((1 2) (3 4) (5 6))), or even the partial application version. And even so, this strikes me as more similar to a request for explicit partial application, which is already implementable, than implicit partial application.

-----

4 points by cchooper 6077 days ago | link

Yes, it was the conciseness I was after. The syntax was inspired by K, where you can do this by putting a ' before a function name.

Of course, K often looks like line noise, but then K takes this technique to its logical conclusion and uses special syntax for everything. There's no need to go that far.

-----

1 point by Jekyll 6094 days ago | link | parent | on: Top 10 differences between Scheme and Arc

join? ?

list? ?

sort? ?

first? ?

It's not doing it for me.

Leaving aside the issues of detecting a query, I think it's a really bad idea to have the compiler force (badly guessed) semantic knowledge on me.

It's my code, I wrote it, and I don't want any compiler telling me that a query that caches previous results must be imperative! and not end in a ? .

I also thing needlessly polluting a namespace with addition symbols is a bad idea. You only get one namespace in arc, try to preserve it for the future.

-----


I can't vote down initial posts in threads, so this isn't going to be much of a poll.

(I'm not saying I want to, it's just that it's not going to tell you anything about what proportion of people like your idea.)

-----

-3 points by drcode 6096 days ago | link

I agree it's a poor poll- I admit it's a silly gimmick pandering for points.

-----

1 point by dplabs 6096 days ago | link

i have to most respectfully disagree friend. so far i like most everything i see in arc, but this ssyntax business does not resonate well with me. i thought it was only me (i'm getting old and all) but now i see some other people that are bothered by it so i feel i should say something. i think there is something to this.

-----

6 points by Jekyll 6098 days ago | link | parent | on: Top 10 differences between Scheme and Arc

Scheme has arrays. Arc doesn't yet. Arc has a generic setter = . Scheme doesn't.

-----

1 point by sacado 6098 days ago | link

Yes, arc has arrays, in the libraries of the unofficial version.

-----

4 points by almkglor 6098 days ago | link

This "array" support is really for an abstract sparse array (with a hashtable implementation). I think what's being referred to is a "real array" (with a sequential-cells-of-memory implementation.)

-----

1 point by Jekyll 6097 days ago | link

That's a shame. I was all excited for a minute.

I guess I'll have start poking about in the source this weekend and see how hard it is to push the functionality up from the underlying scheme.

-----

1 point by almkglor 6097 days ago | link

While you're at it, try to see if it can be pushed up in lib/array.arc on the arc-wiki.

-----

1 point by sacado 6098 days ago | link

Oh, sorry. I guess it has to be added then :)

-----

3 points by sacado 6097 days ago | link

Do you think it is the right thing ? If so, I'll push it to the git. Nothing amazing there, just mzscheme vectors that can be called as hash tables, lists or string. It's got a constructor (vec) and responds to len. Any further function can (should) be written in Arc.

  arc> (= v (vec 10))
  #10(nil)
  arc> (= (v 1) 0)
  0
  arc> (len v)
  10
  arc> (v 0)
  nil
  arc> (v 1)
  0
  arc> (v 10)
  Error: "vector-ref: index 10 out of range [0, 9] for vector: #10(nil 0 nil)"

-----

2 points by almkglor 6097 days ago | link

Looks good. I vote for "push".

Edit: Although it might (?) be better in the lib/array.arc, unless of course it's already integrated into ac.scm...

Edit2: Also, I hope (vec ...) is a function, not a macro or special form, so that existing code that uses vec as a local variable for a collection, or as a function, can still work.

-----

2 points by sacado 6097 days ago | link

It can't be put in a .arc file, since it is pure scheme code. Further functions dealing with vectors should go in lib/array.arc, however. And yes, vec is a function.

-----

2 points by Jekyll 6097 days ago | link

That's awesome, but I've just lost all my motivation to learn git.

Nice work :D.

-----

1 point by sacado 6097 days ago | link

It is still very basic. Many utilitary functions could be added on top of that if you want :)

-----

1 point by sacado 6097 days ago | link

pushed. type on a vector also returns 'vec.

-----


Kenny's right.

Pattern matching is completely orthogonal to hygiene.

You could add in another operator, %, that performs exactly the same as ` but hygienically. Personally I'd settle for just being able embed procedures in code trees like you can in common lisp. Being able to write.

  (let this (fn (x) x)
     (mac na-na-na(y)
      `(,this ,y))) ;Can't touch "this". It's lexically bound.
Allows you to fake hygiene in the common cases where it's needed most often.

-----

4 points by Jekyll 6099 days ago | link | parent | on: NewLISP anyone?

>So what am I missing?

Well last time I looked at newLisp you were missing:

1)closures

2)callcc

3)pass by reference

4)macros (you've only got f-exprs)

5)argument checking for functions at run time

6)a compiler

7)Garbage collection

8)hash tables

I stopped looking after that but I'm sure other people can keep the list going...

It'd be great if I'm wrong about these things and newLisp can be taken seriously, but right now, based on the little I know, I'm not using newlisp.

-----

10 points by dido 6099 days ago | link

I'll add one more thing: static binding. It's the only functional language/LISP dialect I've ever seen developed after the 1970's (besides Emacs Lisp) that still does dynamic binding. I decided that this would be lots of trouble for programming in the large, which is why I never decided to pursue it.

This NewLisp fragment (which is also valid Scheme) illustrates this:

  (let ((x 1))
       (let ((f (lambda (y) (+ x y))))
            (let ((g (lambda (f y) (let ((x 3)) (f y)))))
                 (g f 2))))
This form evaluates to 5 in NewLisp but 3 in Scheme. The equivalent in Arc:

  (let x 1
      (let f (fn (y) (+ x y))
             (let g (fn (f y) (let x 3 (f y)))
                 (g f 2))))
as expected evaluates to 3, so Arc also does static binding. Dynamic binding makes safe use of free variables in different contexts that much harder, and essentially makes referential transparency all but impossible. I cannot for the life of me, especially after reading Steele and Sussman's "The Art of The Interpreter", imagine why the designers of NewLISP thought it would be a good idea to use dynamic binding in their language. Static binding had a reputation in the past as carrying with it a performance hit, which is why RMS didn't use it for Emacs Lisp, but research done afterwards has shown that there are ways of doing it properly that don't sacrifice performance.

-----

1 point by sophacles 6099 days ago | link

Unless I'm not understanding something, and am not quite grokking this whole list/functional language thing (entirely possible I'm still learning).

newLisp appears to have the following from this list (by way of a quick look at the documentation on the site):

macros via define-macro and lamda-macro (and not autmatically hygenic ones...)

pass by reference.

And closures via let and lambda forms.

garbage collection

hash tables

Im really not for or against newLisp. It seems that since you last looked some of the stuff got implemented. The thing Im really not sure of is macros. It seems to me that the newLisp maros are very much the same as arc macros. If this is wrong, can someone please help me grok it?

Erich

-----

11 points by Jekyll 6099 days ago | link

One of the things I don't like about newlisp is that from their site, they appear intentionally misleading about what they can and can't do.

They don't have hash tables, this they openly admit and they make do with self balancing trees.

They don't have macros, they have f-expressions. F-exprs are strictly more powerful, but execute at run time not at definition time. This means every abstraction you use incurs a penalty fee each time it is executed, rather than just once when it is compiled. They call what them macros anyway.

They don't have garbage collection at all. The whole language is basically allocated on the stack, and objects are deleted or copied and returned when a function ends. This means they can't have true closures, or pass by reference with indefinite extent for the objects.

As far as I can tell, the hacks they suggest to get round the lack of closures won't work if you want to create and destroy many anonymous fns. bound to data with indefinite extent. They still refer to these hacks as `closures'.

Their pass by reference work around, amounts to passing symbol names from different contexts and can't do the right thing when you(for example) want to merge existing lists and then rebind one the original symbols.

Having said all that, if one of the newLisp guys wants to prove me wrong, and show something like partial application code to demonstrate that it really does have true closures, it'd be great to see, and I'd probably go back to the language and have another go with it.

-----

-1 points by newguy 6098 days ago | link

"...if one of the newLisp guys wants to prove me wrong," No, first you have to prove yourself right.

"...they appear intentionally misleading..." Intentionally? How so?

"...they still refer to these hacks as `closures'." Cite please. And "hacks"? What if I called you a jerk?

-----

9 points by Jekyll 6098 days ago | link

>No, first you have to prove yourself right.

Can't prove a negative, but I've already explained why I think I'm right.

>Intentionally? How so?

When they claim to fake closures with contexts, they're wrong. Now they're either confused or trying to confuse other people.

>Cite please.

"In newLISP lexical state-full closures are not realized using lambda closures but using lexical namespaces." http://www.newlisp.org/ExpressionEvaluation.html

It's the first hit on google for `newlisp closure'.

>What if I called you a jerk?

I would be immediately converted to newlisp by the strength of your arguments and the size of your e-penis.

-----

1 point by cooldude127 6099 days ago | link

those sound like a lot of things i want. sorry newlisp

-----

5 points by Jekyll 6105 days ago | link | parent | on: Another, older wannabe neo-Lisp

Qi is completely type inferring, so it proves the type correctness of the code at compile time from a minimum number of declarations, like the ML family of languages.

However, as this is optional, it can also be switched off in places to handle code that the type system can not prove correct.

To make a similar system work, you'd have to label the inputs and return type of each function, and enforce the consistency of this, all at compile time. There is a complete prolog system buried in QI allowing the types to self reference and be turing complete in terms of complexity.

Having said that, the whole of QI is only meant to be 4k lines of common lisp and under an MIT license, so it'd be quite easy to port the interesting bits of it once the core of arc has stabilised.

-----

1 point by ryantmulligan 6105 days ago | link

pg, I was referring to Jekyll's explanation of optional typing. The 'maybe' means that I don't know the value in it, I've just heard that some people like it.

-----

2 points by jules 6102 days ago | link

How can Qi be type inferring when its type system is turing complete?

-----

1 point by Jekyll 6101 days ago | link

IRC, the type inference is not guaranteed to terminate in pathological cases.

-----

0 points by jules 6048 days ago | link

You mean type checking.

-----


Typically, people optimise for speed and not terseness in the shootout. If you look at how the languages perform in terms of terseness you find:

Dynamic languages with no possibility of optimal type declarations come first, followed by statically typed type inferring languages, then a ragbag of stuff including dynamic languages with optional type declarations like SBCL.

Then Java and Ada at the back.

You want the lisp to be shorter? Try taking out the type declarations. They're optional.

-----

1 point by Jekyll 6106 days ago | link | parent | on: Stupid noob question

Dr Scheme does. Fire it up, click language then choose language. Pick "pretty big", then (define-macro ...) will do pretty much what you expect. http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-...

-----

1 point by mec 6106 days ago | link

Side question here, is there a keybinding anywhere in DrScheme to close all open parentheses? It's driving me crazy trying to find it.

-----

1 point by danielprager 6106 days ago | link

Dunno, but the '[' and ']' keys in DrScheme are clever enough to give you '(' and ')' when you need them (and '[' and ']' at other times).

Since discovering this I just keep tapping ']' until the highlighting tells me I'm done.

-----

2 points by Jekyll 6110 days ago | link | parent | on: Reference parameters

This behaviour is already standard in all lisps. Try: (with (a (list 1 2) b [ = (car _) 3]) (b a) a)

=>(3 2)

the list (1 2) is passed to function b, which modifies the car of the first cons cell, changing the original list.

-----

2 points by cadaver 6109 days ago | link

I'm new to lisp/scheme/arc so this may not be an issue in practice, but what if you want to add a new pair to the beginning of the list?

The only way to do this would be to insert a new pair after the first, then copy the car from the first to the second, then set the first car as desired.

Unfortunately this does not work if you have references to this first pair in particular, because of its car, rather than because it is the beginning of the list;

-----

1 point by cadaver 6108 days ago | link

Now that I think of it, passing parameters by reference would not be useful in this case.

Passing lists (pairs) by reference simply means creating a level of indirection to where the address of the first pair is stored. However, in a running program, there can be an arbitrary number of such locations.

I think that the problem of lists, of which the sort order is significant and which may be modified in arbitrary ways, can only be solved by, a) having a global binding, that is, a global level of indirection that everyone uses, or b) using a pair, of which the cdr remains unused, or some other reference-object as a level of indirection.

I suppose this is where arrays come in.

-----

1 point by Jekyll 6107 days ago | link

My example wasn't exactly orthodox lisp style. Normally, you should explicitly set any variables you are manipulating, so you'd be writing: (= a (f a)) rather than relying side effects to set it for you (This is especially important when calling functions like sort). It's such a common idiom that in common lisp I have a ! macro to turn (! f a . b) into (setf a (f a . b)).

-----

More