Arc Forumnew | comments | leaders | submit | jmatt's commentslogin
2 points by jmatt 6328 days ago | link | parent | on: (delist somelist)

(flat (list (list 1 2) (list 3 4))) will do it.

I've used flat before and it's worked well.

reference: http://www.arcfn.com/doc/list.html

-----

1 point by bOR_ 6328 days ago | link

Hmm. Seen flat and tried it. in Arc2 flat works recursively, turning (list (list 1 2) (list (1 2)) into (1 2 1 2), which doesn't produce the desired (2 4) when combined with map +

  (map + (flat (list (list 1 2) (list 1 2))))
  (1 2 1 2)

-----

9 points by almkglor 6328 days ago | link

  (apply map + your-expression)

-----

3 points by bOR_ 6328 days ago | link

  (apply map + (map vals:craa!eltm:car (observecone craa!pos (list 0 359) craa!range)))
  (122 31 0)
Thanks! I'll digest what things you can do with the apply map combination in my sleep, but it seems quite handy.

-----

2 points by absz 6328 days ago | link

The apply function takes a function, any number of arguments, and a list, to wit (apply f x0 x1 x2 ... xN args). This is the same as (f x0 x1 x2 ... xN args.0 args.1 args.2 ... args.M). This allows you to construct argument lists at runtime, which can come in very handy.

-----

2 points by jmatt 6328 days ago | link

almkglor nailed it.

That's elegant and simple.

-----

8 points by jmatt 6328 days ago | link | parent | on: Chalk one up for Arc

I agree whole heartedly with this. I have begun abbreviating too.

I think arc like macros should go in Anarki. What does everyone else think? I like seeing everything arc in one place - even if it is CL or Scheme macros.

That being said it sucks that the arc community uses Anarki while pg doesn't. Or at least he doesn't contribute regularly. I think there is plenty of room for a more cohesive community.

-----

5 points by almkglor 6328 days ago | link

> That being said it sucks that the arc community uses Anarki while pg doesn't. Or at least he doesn't contribute regularly. I think there is plenty of room for a more cohesive community.

Second that!

-----

5 points by stefano 6327 days ago | link

Cohesion is the real big problem of the Lisp community in general, and it should be addressed by Arc. In this respect I think that Anarki is what the official version of Arc should look like: one place were everyone can contribute.

-----

3 points by almkglor 6327 days ago | link

LOL. Let us therefore officially decree that Anarki is the official Arc. ^^

-----

3 points by stefano 6327 days ago | link

That's right! :)

-----

3 points by almkglor 6326 days ago | link

LOL. And therefore ArcN is the Decreed Unofficial Canonical Arc.

-----

1 point by jmatt 6332 days ago | link | parent | on: Why Arc is bad for exploratory programming

I posted this over on hacker news - but it should be here too:

http://news.ycombinator.com/item?id=191501

If arc could seamlessly access PLT scheme's libraries that would be a good start. I know from first hand experience that there are a number of ways to access PLT scheme from arkani and arc. But, there are two big issues. First there are type differences between fundamental types (lists gah). This means there can be a lot of work to convert between PLT scheme and arc, not impossible but time consuming. Secondly, there is no nice way to pull in a PLT library and just use it in arc. Of course this could be implemented - it's just not there yet.

There are two choices I see going forward immediately. Arc and the arc community starts implementing their own libraries or we find a way to use PLT scheme's libraries (ok maybe sbcl if you are using arkani).

-----

1 point by jmatt 6332 days ago | link

there is some discussion on accessing PLT scheme's libs over here: http://www.arclanguage.com/item?id=6757

I know there is additional information somewhere in the forum on type differences when coercing data between scheme and arc - specifically '() nil (list) aren't equivalent. Worse come to worse - see the source.

-----

4 points by almkglor 6332 days ago | link

There are a bunch of functions on scheme-side ac which help in conversions.

For functions returning booleans, there's 'tnil:

  (xdef 'exact (lambda (x) 
                 (tnil (and (integer? x) (exact? x)))))
For functions whose return value isn't used, you can use 'wrapnil:

  (xdef 'system (wrapnil system))
'ac-denil converts plain nil to 'nil, and nil at cdr positions into '().

  (define (expand-ssyntax sym)
    (ac-denil ((eval '__ssexpand) sym)))

-----

2 points by absz 6331 days ago | link

Nitpick: Anarki is the git repo, Arkani is the wiki written in Arc.

-----

2 points by jmatt 6331 days ago | link

Yeah thanks for pointing that out. My bad. Those damn names are so similar and I have my gits all scripted.

-----

4 points by eds 6331 days ago | link

http://arclanguage.org/item?id=5259

-----

2 points by jmatt 6353 days ago | link | parent | on: Smalltalk vs LISP

Great point about uniformity.

In lisp everything is a list - even code.

In smalltalk everything is an object - even code.

I think macros in smalltalk are plausible. I have nothing to back that up. I am definitely not a smalltalk hacker. I think that smalltalk can solve the same problems that macros solve just through a different approach.

-----

1 point by schtog 6353 days ago | link

yes that was kind of my thought. but i dont know enough about either language yet.

-----

8 points by jmatt 6353 days ago | link | parent | on: Smalltalk vs LISP

I saw this quote over on the onsmalltalk.com page and thought it was accurate, "I’ve always felt Lisp is the superior language and Smalltalk is the superior environment." (http://onsmalltalk.com/programming/smalltalk/aha-moments-in-...).

Considering that arc doesn't even have slime support - it's accurate. Now when using slime supported lisps, the environments are at least comparable. Debugging in Smalltalk is awesome and straightforward after you are up to speed. It still takes more dedication to learn slime well enough to debug a gnarly bug.

Both smalltalk and lisp will allow you to create DSLs (domain specific languages) easily for your application. Both see code as data and allow customization of internals. They do this through different approaches. Each approach has different strengths and weaknesses. Also some people are just more comfortable with one approach over another.

I think it speaks volumes about Smalltalk that Avi Bryant could just add continuations (saved closures) to the language for seaside. This sort of ability to add powerful new forms to a language is key and helps set it apart from other languages and put it in the same category as Lisp.

If you are interested there are interesting "History of" papers on Smalltalk and Lisp from the HOPL ACM conferences. They help explain the different philosophies in detail and do a great job of explaining why each language is the way that it is.

I was talking to a fellow lisper recently and he said "If I weren't writing lisp or scheme, I'd be writing smalltalk". I entirely agree with that. In fact I may still end up writing some projects in smalltalk.

-----

4 points by jmatt 6353 days ago | link

Here are some links. I realized some of the things that I mentioned may be hard to find.

Both hopl papers are available on the digital library on the acm website. Here are the free links:

History of Lisp (John McCarthy) - http://www-formal.stanford.edu/jmc/history/lisp.ps

History of Smalltalk (Alan Kay) - http://stephane.ducasse.free.fr/FreeBooks/SmalltalkHistoryHO...

Seaside (the killer app for squeak/smalltalk) - http://www.seaside.st/

-----

2 points by eds 6353 days ago | link

Do you have any suggestions for learning slime? I've always felt that I wasn't taking advantage of its full potential.

-----

5 points by jmatt 6353 days ago | link

Unfortunately I don't have any huge insights. I've been using it on and off since 2005. It was recommended by a friend who lives in emacs. It makes lisp approachable and it makes me way way more efficient when writing and debugging lisp. No swank backend (and thus no slime) makes arc a hard sell. For those wondering what's so great about it - slime supports every major debugging feature I've seen in Eclipse or Visual Studio.

This is what I would recommend for someone learning slime:

If you are a complete slime n00b watch the screencast over at the slime homepage. I just watched it recently and it is well done.

I think the best way to learn from there is through using it to implement a non-trivial yet small project. Make sure the project isn't too challenging, so you have a chance to learn the new environment. Anytime you think there must be an easier/better way to do this - spend time learning slime. Keep coding and you'll continue to put yourself into situations where you can use slime in new ways.

If you have specific questions or problems it is worth asking the community or searching blogs / mailing lists. The questions are either answered already or someone will give you an answer. This is much like all the lisp and smalltalk communities.

I will see if I can get an expert slime user to post some more specific information. Maybe someone else can chime in. I know I have some useful information on specific parts of slime but it wouldn't help someone that is a new user.

links: home - http://common-lisp.net/project/slime/

screencast - http://www.cl-user.net/asp/web-sites/slime-video

manual (also around in ps and pdf) - http://common-lisp.net/project/slime/doc/html/

-----

2 points by jmatt 6355 days ago | link | parent | on: ffi sqlite3 - help

Thanks for the help. I'll test this out tonight.

Good to know that C NULL == mzscheme's #f.

-----

6 points by jmatt 6355 days ago | link | parent | on: Lispy web development alternatives

Interesting! I just had this conversation with a fellow lisp hacker yesterday. What are the alternatives to arc? Or more precisely why not choose one of these other continuations based web frameworks over arc's web framework?

CL:

UCW - http://common-lisp.net/project/ucw/features.html

hunchentoot - http://weitz.de/hunchentoot/

weblocks - http://common-lisp.net/project/cl-weblocks/

Scheme (gauche):

kahua - http://www.kahua.org/show/en

Outside the lispy box - smalltalk:

seaside - http://www.seaside.st/

A thread on an actual enterprise web based lisp system:

http://groups.google.com/group/comp.lang.lisp/browse_thread/...

On top of this consider that if you use something like sbcl you'll then be able to use slime and all that it adds when debugging. Also you'll get a number of relatively stable libraries without having to port them to arc.

http://common-lisp.net/project/slime/

You also get some nice persistence libraries such as elephant in CL. These could make life easier if you had complex objects or structures that needed more than just hashs.

http://common-lisp.net/project/elephant/

I think the number one thing plaguing SBCL is multiple threads causing problems. A friend mentioned that hashes should be threadsafe now. That is a move in the right direction. I know I've had problems with threading in SBCL in the past, but that was years ago.

I have thought about what my back up is if I run into too many problems in arc or lisp. Especially if I needed to hire people or contract work. I have my own ideas for how to address such problems, but I think it should be kept in mind when making a decision as to what framework and language to use.

There are public lispy web apps out there. I just don't have a list of them right now. Notably reddit was written in common lisp. I believe sbcl was used, but not sure. Later on it was rewritten in python. The reason is undisclosed but if I had to guess I would say issues with threads.

-----

4 points by kens 6355 days ago | link

The reasons stated for the reddit move off Lisp are poor portability, lack of libraries, and a threading stability problem. See http://blog.reddit.com/2005/12/on-lisp.html and http://www.findinglisp.com/blog/2005/12/reddit-and-lisp-psyc...

-----

2 points by jmatt 6359 days ago | link | parent | on: ffi sqlite3 - help

Ok here is a more specific question.

Given this C and ffi declaration:

  ;int sqlite3_exec(
  ;  sqlite3*,                                  /* An open database */
  ;  const char *sql,                           /* SQL to be evaluted */
  ;  int (*callback)(void*,int,char**,char**),  /* Callback function */
  ;  void *,                                    /* 1st argument to callback */
  ;  char **errmsg                              /* Error msg written here */
  ;);

  ;sqlite3_exec
  (cdef sqlite3-exec "sqlite3_exec" cint (cptr cstring cfptr cptr cstring))
Why is this call to it seg faulting (for details on parameters see load code above):

  (sqlite3-exec sqlite3 sqltxt (topcb) sqltxtptr sqlerrormsg)
Does this work for anyone else? Is there a problem with my parameter delcaration / setup?

Thanks ~

-----

1 point by sacado 6357 days ago | link

On the Arc level, it works perfectly well for me (no error, no segfault). But, when I try to (manually, with vi) open the db file (the "test" file), it's empty. Existing, but empty. I don't know why yet.

There's one thing that seems strange to me in the above declaration : char errmsg should not be declared as a cstring : it is a pointer to a string. I guess it should be declared as a cptr. I'll investigate more deeply later, when I'll find enough time...

-----

2 points by jmatt 6356 days ago | link

Yeah that is definitely a problem. I will work on this again tonight and see if I can get somewhere.

-----

2 points by sacado 6359 days ago | link

I'll try that & see if I can help you...

-----

1 point by jmatt 6359 days ago | link

Awesome, much appreciated.

-----

1 point by jmatt 6360 days ago | link | parent | on: Macro trouble

xs will have a type of 'cons in this situation. Which means it sees it as (element . list). So for your example it'll see it as 3 (3 4 5 66 67). It just happens that pr deals with cons types well.

If you wanted to return another value, you could.

  (mac meta xs `(do (pr ,@xs) (last ',xs)))

  arc> (macex '(meta 1 2 3 4 5 6 7))
  ((fn () (pr 1 2 3 4 5 6 7) (last (list 1 2 3 4 5 6 7))))

  arc> (meta 1 2 3 4 5 6 7)
  12345677
Another way to return the last element of fn...

  (mac meta xs `(do (pr ,@xs) ,@xs))
  
  arc> (macex '(meta 1 2 3 4 5 6 7))
  ((fn () (pr 1 2 3 4 5 6 7) 1 2 3 4 5 6 7))
  
  arc> (meta 1 2 3 4 5 6 7)
  12345677

-----

1 point by jmatt 6360 days ago | link | parent | on: Macro trouble

Check out the definition for pr on arcfn. http://www.arcfn.com/doc/io.html

Prints arguments using disp. Returns the first argument.

-----

More