#clojure logs

2009-01-18

01:10technomancyI'm trying to read-line from a socket... the docs imply that it works on streams, but it doesn't work with the java.net.SocketInputStream that I get back from (.getInputStream socket)
01:11technomancymaybe I need a reader? how does that work?
01:14Carkuse an InputStreamReader
01:16technomancynope, not quite: No matching method found: readLine for class java.io.InputStreamReader
01:16Carkthat's only the first step i guess let me see
01:17durka42perhaps a BufferedReader?
01:17Carkah there you go
01:18Carkstill need the InputStreamReader though
01:18technomancyI guess there's still a ways to go before claims of low-ceremony can hold. =\
01:18technomancythanks tho
01:18durka42i wonder if contrib.duck-streams/reader can handle sockets
01:18technomancywas about to wonder aloud about duck-streams...
01:18technomancywill peruse the source
01:19durka42" Argument may be an instance of Reader,
01:19durka42 BufferedReader, InputStream, ...."
01:19Cark(-> (.getInputStream socket) InputStreamReader. BufferedReader.) will get something which you can readline from i suppose
01:22Carkthat's how they do it in duck-streams anyways
01:24technomancyI'd like something clean; duck-streams looks best.
01:24technomancyof course, that means figuring out how to put contrib on my path. grrr...
01:25durka42just add the jar to the classpath
01:26Carkfunny i'd rather avoid the dependency. Seems longer but it conveys the meaning pretty well
01:27Carkyou only need it in one place in your code, so there's no need for more abstraction
01:27Carkexcept maybe for the polution of your ns form
01:27technomancywell, I'm sure I'll be using other things from contrib eventually
01:27technomancythere's no need to go into that level of detail just to say "I want a line. From this socket... capiche?"
01:27Carkhehe sure, that's matter of opinion anyways
01:28durka42yeah, one of my gripes about java is the long lines of nested constructors just to say something like that
01:29technomancyit's pretty silly. good thing we've got duck-streams.
01:29Carkthere's no nesting required with clojure !
01:29technomancythere was talk of duck-streams going into core; is that right?
01:29durka42anyway, (Thread/sleep)
01:29durka42goodnight
01:29Carkbye durka
01:32technomancywhat's the function to find if a symbol has a binding?
01:32technomancy(boundp in CL)
01:39Carki don't think there's a way
01:45technomancyheh; all the google hits are for clojure Emacs code
01:45technomancyclojurebot: bound?
01:45clojurebotexcusez-moi
01:58hiredman,(find-var (symbol "println"))
01:58clojurebotjava.lang.IllegalArgumentException: Symbol must be namespace-qualified
01:59hiredman,(find-var (symbol (name *ns*) "println"))
01:59clojurebotjava.lang.IncompatibleClassChangeError
02:00hiredman,(find-var (symbol (str *ns*) "println"))
02:00clojurebotnil
02:01technomancythanks hiredman
02:02hiredmanwell
02:02hiredmanit makes symbols
02:03technomancyoh, totally misread that.
02:03technomancyso it's like intern
02:05technomancythanks
02:05technomancytime for some shut-eye for /me
02:55hiredmanjava.io.FileNotFoundException: Could not locate hiredman/clojurebot/core__init.class or hiredman/clojurebot/core.clj on classpath: (clojurebot.clj:0)
02:55hiredmandamn
03:09hiredman,(doc partition)
03:09clojurebot"([n coll] [n step coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap."
03:23Lau_of_DKTop of the morning gents
03:24kotarakMorning Lau.
07:23mibuanyone knows how to change parentheses' color to DimGray in clojure-mode?
08:20Chousukehmm
08:29Lau_of_DKChousuke: Thinking out loud?
08:31ChousukeJust wondering what exactly does *print-dup* do :/
08:31Chousukeand what's the point of *print-readably*
08:33kotarakI think it prints things like, eg. sorted-map, as #=(sorted-map ....). So it can be read again. Otherwise it's printed as {} and would result in a hash-map when read.
08:34Chousukealso, for documenting these variables, would it be enough to simply add the documentation at the end of core.clj?
08:35kotarakWhy at the end?
08:37Chousukewell, adding the documentation is easier if I can use set-meta! and defmacro
08:38kotarakIs that so much easier than a #^{:doc ...} where the are def'd?
08:38Chousukeyes, because some of them are def'd in java code.
08:38kotarakOk. That's a problem, I guess.
10:01edwThe documentation to COND is written in such a way as to suggest it looks like a traditional COND. Or, alternatively, I am not reading the definition closely enough. "Takes a set of test/expr pairs." That screams "(cond (test expr) (test expr))" to me. If it did work like a traditional CONS, how would it best be described?
10:08Chousukehmm
10:10Chousukewell, it doesn't work like COND in CL; but I wonder how to best describe that.
10:12edwRight. In fewer then a jillion words.
10:13edwOof! s/then/than/
10:14Chousukeyou could mention that "the result expressions are not wrapped in an implicit do block"
10:14Chousukebut that would probably confuse CL'ers even more...
10:15edwThis BTW is one of the regrets McCarthy expressed re: the original LISP design.
10:15arbscht_clhs uses a modified BNF for a reason :)
10:15edwA series of alternating test and expression forms?
10:15Chousuke"cond takes an even number of forms, interpreted pairwise as a single test expression and a single result expression."
10:16edwA series of alternating test and expression expressions?
10:16kotarakHow about not taking notions of CL over to Clojure? A "pair" in the CL is completely uninteresting in Clojure.
10:16edwYes, we saw the movie.
10:18edwkotarak, oh language notion guardian, does the concept "form" exist in Clojure?
10:19edwAnd does "expression" imply a "normal", non-macro, non-special form?
10:20kotarakedw: I didn't say I am a guardian of what so ever. I just made a suggestion, that leaving notions from CL at CL and read Clojure as Clojure. Maybe then it's easier to get along with the syntax.
10:25edwBut your comment does bring up a good point. What is the vocabulary that people should be using to discuss concepts in Clojure. Taking Scheme as an example, a "procedure" is something that computes the value of a function, a definition much different than most other programming languages, and I'm careful when discussing Scheme to respect that definition. In Clojure, a "function" computes a function, so I use that word.
10:29edwThe "don't use pair" rule is a no-brainer, given the explicit discarding of pairs in Clojure. I didn't think the "pairwise" usage in Chousuke's comment was a technical usage, simply a plain-English usage, those my jumping down your throat.
10:29edws/those/thus/
11:03wlrkotarak: you said 'A "pair" in the CL is completely uninteresting in Clojure.' A "pair" is a Scheme, not, CL, term. Also the closest, but different, concept in CL for Clojure's cond arguments is "property list".
11:04Lau_of_DKGood evening gents
11:05kotarakwlr: I have only Scheme background, no CL. So if pair is not CL term, then be it. I just suggest, that looking at the code as Clojure code and not as language X code, could help to overcome such problems.
11:06kotarakI remember this troll, who started on the google group with "Why does (define (foo bar) ...) not work?".
11:08wlrkotarak: i agree with your larger point, just a one-time nitpick regarding the details. :)
11:28edwkotarak: So if you have no CL background and therefore have no knowledge of whether or not "pair" is an "interesting" concept in CL, why did you write what you did? If you're going to play the part of a know-it-all, you should probably make sure you do in fact know it all in whatever domain you're swinging your dong.
11:28rhickeyedw: we don't talk to each other like that here
11:29rhickeythere's no reason not to be respectful
11:30edwI apologize.
11:37edwThe example for the `def' special form uses a `defn' as an example.
11:37karmazillanewsflash: textjure* now has a GUI for opening and switching between files! :D
11:38Lau_of_DKWohoo :) Where are you hosting it ?
11:38kotarak\o/
11:39karmazillaon github: http://github.com/karmazilla/textjure/tree/master
11:40Lau_of_DKOh yea.. Right next to http://github.com/Lau-of-DK/clojureql/tree/master
11:40Lau_of_DKI'll check it out :)
11:41karmazillait's only an editor for people who don't need all these modern bells and wistles such as syntax color, indenting, and... oh, I don't know, _closing_ files :)
11:42Chouserheh. well, karmazilla, you have now touched more lines of textjure than I have. Congrats!
11:46Chouserkarmazilla: are you able to use textjure to work on textjure code yet, or is it still too young?
11:46Chouserbah
11:49Chouserkarmazilla: are you able to use textjure to work on textjure code yet, or are the features you need not quite there?
12:04danlarkinhiredman: checking my RSS feed now... you know you don't have to push to github every time you commit :-p
13:23Lau_of_DKGood evening gents
13:26danlarkinafternoon Lau
13:26Lau_of_DK:)
13:30Lau_of_DKdanlarkin: What are you working on these days?
13:30danlarkina yet-to-be-released port of django to clojure
13:31danlarkinmostly-port
13:31danlarkinsome things I'm changing as I go
13:32Carklisppaste8: url
13:32lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:33danlarkinI think I will be using clojureql to build the ORM
13:33lisppaste8cark pasted "huh ?" at http://paste.lisp.org/display/73813
13:34Lau_of_DKdanlarkin: Sounds very interesting, got it hosted somewhere?
13:34Carkanybody has an idea on why this is not working ?
13:34Carkwhen evaluationg the macroexpanded form it works but not the macro itself
13:34Lau_of_DKdanlarkin: And also very interesting about CQL - I would be very interested in all feedback you might have
13:36ChousukeCark: why do you evaluate the AbstractAction?
13:36Carkahhh yes must be that !
13:37Carkright that's it, thanks
13:37danlarkinLau_of_DK: no, it's not hosted anywhere yet, I want to have it at least to a "usable" state before I put it up anywhere. I don't expect anyone to use it, but I at least want to add docstrings and stuff before I release it for others to see
13:38antifuchsdanlarkin: sounds like a big project.
13:38Lau_of_DKSo ehm... Hurry up and add some docstrings :)
13:38antifuchs(also, yay, would be very interested in seeing it)
13:38danlarkinantifuchs: it is... probably too big
13:38danlarkinI'm very happy with my progress so far, though
13:39Lau_of_DKdanlarkin: How much do I get for free when using cjango, compared to compojure?
13:40danlarkindefinitely not calling it cjango :)
13:40Lau_of_DKhehe, sorry :|
13:40Chousukecongo? :(
13:41antifuchsdjosure?
13:41Chousukeclango!
13:41danlarkin100% no way it's ending in -jure
13:41antifuchstee hee
13:43Lau_of_DKClangojure, pronounced like Klank-GO-sjuuuure
13:43danlarkinLau_of_DK: are you familiar with django at all?
13:44Lau_of_DKNo, I just skimmed their website
13:44danlarkinLau_of_DK: that would help illustrate what you get "for free"
13:44danlarkinah
13:44Lau_of_DKAnd how are you porting it? Do I get both Clojure and Python overhead?
13:44danlarkinno no
13:44danlarkinI'm rewriting it
13:46cmvjkl_what's the easiest way to check and see if a variable is a number?
13:47cmvjkl_there's not a specific function for it is there?
13:47danlarkinit is a lot of work though, so I would like some help eventually :)
13:47Carkin the rewriting department i'd love to see a port of hunchentoot
13:47Chousukecmvjkl_: number? perhaps
13:47Chousuke(doc number?)
13:47clojurebotReturns true if x is a Number; arglists ([x])
13:47cmvjkl_oh man, there is.
13:48cmvjkl_my fault, but to be honest, there should be an easier way to look that up too...under the data structures page for 'numbers', that isn't listed at all.
13:48Lau_of_DKdanlarkin: Thats sounds like a huge job - You should consider doing a 'linus' on it :)
13:49danlarkinLau_of_DK: and what is a 'linus"?
13:50Chousukecmvjkl_: find-doc is your friend )
13:50Lau_of_DKdanlarkin: Thats a 'delegate wildly' approach to writing software
13:50Lau_of_DKwhich means, Git :)
13:50danlarkinit's in git :) just not anywhere except my computer
13:50cmvjkl_oh man i didn't realize that existed either. thanks!
13:52danlarkinreally the only people who could help with the major stuff at this point are those extremely familiar with django and all the python tricks they use, and with a working knowledge of clojure
13:52danlarkinwhich might be like
13:52danlarkinonly me
13:52danlarkinhahah
13:57Lau_of_DKhehe - Im really biting my tongue not to say something right now :)
13:57danlarkina python diss?
13:58danlarkinbah!
13:59ChousukeI think everyone knows Lau_of_DK's opinion of python by now.
13:59ChousukeI also think you're wrong, but I'm not willing to debate that here.
14:00danlarkinyes no sense in flame wars
14:11Lau_of_DKdanlarkin: It was actually a mounting flamewar which got me into SBCL from C# :)
14:11danlarkinha
14:11danlarkinso maybe there is sense in flamewars?
14:12Lau_of_DKor maybe I just caught a break :)
14:13Lau_of_DKI mean, all the stuff being said was lame and hurtful, but one guy shot of some Lisp to prove his point, which he did well enough
14:15danlarkinwell that's good
14:15danlarkinit's rare for something positive to come of bickering
14:17Lau_of_DKTrue
14:25danlarkinthe only feature I haven't been able to match 100% from django yet is their url dispatch can use named groups
14:25danlarkinand java's regex engine doesn't have named groups
14:25antifuchsmight try porting cl-ppcre (:
14:26danlarkinhaha
14:26antifuchshey, it would be neat to compare speeds
14:26danlarkinI think I'll stick with unnamed groups until someone else does the heavy lifting
14:32danlarkinantifuchs: are you familiar with django at all? or are you just interested in the project in general
14:33antifuchsdanlarkin: I am working on a rails project, and am hearing left and right that django would be much better
14:33antifuchsthat is most of the familiarity I have with django itself (:
14:34danlarkinwell I've never used rails myself, but I know a lot of people that have moved rails->django, and zero django->rails :)
14:34antifuchsyeah, I bet
14:34antifuchs((-:
14:35danlarkinright now I could use joshua choi to help me use his fnparse library :)
14:36antifuchsanyway, I would love to have something lispy (and sane enough to show to my teammates and not have to tell them that the ANSI committee didn't think this concept would one day dominate the world) to do this in (:
14:40danlarkinmaybe I'll post to the group when I decide to put it on github
14:41Lau_of_DKYou do that - Im looking forward to seeing it
14:41Lau_of_DKWhich license are you putting it under?
14:41danlarkinBSD
14:41Lau_of_DKWhy?
14:42danlarkinbecause I like free code
14:42Lau_of_DKSo why not EPL?
14:42Lau_of_DKOr LGPL?
14:42danlarkinwhy not just BSD
14:43danlarkinbsd is compatible with both of those licenses
14:43Lau_of_DKArent you forcing me to answer your question now?
14:45danlarkinare you asking me why I don't want a more restrictive license?
14:46antifuchsmay be interesting to get a lawyerly opinion on whether lgpl is more compatible with clojure code than with cl code
14:46Lau_of_DKI understand GPL, LGPL, CPL and EPL fairly well, and I understand EPL to be very free, without any unessarcy restrictions. But I dont understand BSD or what it offers compared to one of the others
14:47antifuchsAIUI, lgpl has very explicit terms defined that probably don't work with languages that have macroexpand
14:48antifuchsIANAL and have been told this only by nonlawyers wo took this issue with regards to CL code up to rms, also not a lawyer
14:48mattreplBSD is short and very free: http://www.opensource.org/licenses/bsd-license.php
14:48antifuchsso well. lawyers would be nice to have... especially those who know lisp (:
14:49apage43also i keep trying to get my paralegal buddy into lisp but meh
14:50danlarkinmattrepl: that version is known as the 3-clause BSD
14:50danlarkinan author can omit any (or all) of the 3 clauses at one's leisure
14:50mattreplthe simplified one is mentioned in the text as well.. just remove the third clause about endorsement
14:51danlarkinI'm using 3 clauses for clojure-json
14:51mattrepldanlarkin: interesting. hadn't heard of that, thought it was only the third one.
14:52danlarkinmattrepl: well it's customary to use either 1 & 2 or 1, 2 & 3... but it's up to the author. The license could say "You can't use this work on tuesdays" and it would be just as binding
14:53apage43http://sam.zoy.org/wtfpl/
14:53mattrepl=)
15:41rhickeyis (educe iter enum) too subtle/cute/quirky for "Runs the enumeration into the iteratee and returns the result", for LFEs i nthe style of: http://okmij.org/ftp/Haskell/Iteratee/DEFUN08-talk-notes.pdf
15:43Lau_of_DKToo cute for what purpose? A presentation of sorts?
15:53rhickey(educe ((comp (ifilter even?) (imap inc)) (ifold + 0))
15:53rhickey (ecat (erange 100) (erange 100)))
15:53rhickey5000
15:54Chouserwhat's the etymology of 'educe'?
15:54danlarkinlooks like haskell with parens
15:54Chouseroh, i see
15:55rhickeydanlarkin: the Haskell looks a lot worse, IMO
15:56rhickeyChouser: "lead out", also a pun on reduce
15:59lisppaste8rhickey pasted "LFE stuff" at http://paste.lisp.org/display/73823
15:59rhickeyfor those wanting to play along ^^
16:01AWizzArdrhickey: could you maybe add something like (defn pipe [& fs] (apply comp (reverse fs))) to Clojure? Or is that not needed iyo?
16:02rhickeyAWizzArd: I haven't needed it yet
16:02AWizzArdin some situations it could make things a bit more readable than comp, and easier to think about
16:04rhickeyThat LFE stuff is as simple as I can make it, and yet I'm still concerned about the complexity of te model and ability of people to write their own enums/iters
16:04rhickeyplus I hate the names
16:05danlarkinI'll say I hate the names too... even though I have no better ones
16:08rhickey"iteratee" in the original work is particularly bad. I think accumulator might be better
16:09kotarakhow is io-scope (or what it is called now) coming along?
16:10rhickeykotarak: io-scope is fine, and a nice idea in general. I think it handles the resources management problem at least as well as LFEs
16:10kotarakwill it be included soon?
16:10rhickeyjust looking at LFEs for feasibility, also they are purely functional while streams are very much not
16:16ChousukeI find that LFE stuff difficult to understand :/
16:17AWizzArdrhickey: can you already say something about the performance?
16:18rhickeyAWizzArd: of LFEs?
16:19AWizzArdyes
16:21rhickeyless overhead than seqs
16:21AWizzArdactually they could be interesting for a proxy server/request broker that I will soon begin to implement
16:21rhickeybut the value is not perf, but resource management safety when used with resource-based sources
16:21ChousukeIt seems to me that first you compose "iterator transformers" (ifilter and imap), then feed an "iterator operation" (ifold) to produce the final iterator that will consume the enumeration somehow. but it still escapes me how educe works. ...hmmh
16:22Chousukecould seriously use some kind of visualisation of what the hell is happening. :)
16:24rhickeyenums are logical collections of items represented by a function that, when passed an iter, feeds each item to the iter. An iter can accumulate anything it wants to, and can signal early termination of the enumeration
16:25Chousukeso a single iterator can gobble multiple items of the enumeration
16:25rhickeyimap and ifilter are iter transformers, yes
16:26rhickeystill missing is ichain, which will allow a set of iters to act sequentially as one iter
16:26Chousukeat one "step" that is, before yielding output to to the "next" level in the transformation chain? or does every transformer have access to all of the enumeration somehow?
16:27rhickeyChousuke: one item at a time, unlike the paper which passed 'chunks' of items
16:28rhickeybut a stage could collapse (like ifilter) or even expand in passing to next stage
16:29Chousukedefining those things looks really cumbersome though :/
16:30rhickeyChousuke: I agree, the model is rather involved
16:31rhickeybut the usage is straightforward
17:25dnolenis it possible to get the name of a namespace object as a string? I've looked at the API but I don't see anything applicable.
17:25kotarak(doc ns-name)
17:25clojurebotReturns the name of the namespace, a symbol.; arglists ([ns])
17:25kotarak(doc name)
17:25clojurebotReturns the name String of a symbol or keyword.; arglists ([x])
17:27dnolenkotarak thanks, i see it now on the clojure page on namespaces, still getting used to getting around.
17:28kotarakdnolen: np, find-doc in the repl is also helpful to investigate such things.
18:19karmazillaChouser: have a minute?
18:33durka42kotarak: i have a proposal for a gorilla feature
18:53blbrownhere is rich hickey from?
18:56drewrblbrown: NYC.
19:10dnolenis it possible to convert a list/vector of keys and values into a hash-map?
19:11durka42(doc zipmap)
19:11clojurebotReturns a map with the keys mapped to the corresponding vals.; arglists ([keys vals])
19:11durka42is that what you meant?
19:11Chousuke,(apply hash-map '(:a 1 :b 2))
19:11clojurebot{:b 2, :a 1}
19:13dnolenchousuke thanks, zipmap looks useful as well durka.
19:15hiredman,(doc zipmap)
19:15clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
19:54jliIs it just me, or does blip.tv not allow skipping to part of the video you haven't downloaded yet?
20:15blbrownwhat can be done with the 'doc' meta data. Is there a javadoc like tool in clojure?
20:16Chouserblbrown: doc and find-doc use it.
20:16Chouser(doc find-doc)
20:16clojurebotPrints documentation for any var whose documentation or name contains a match for re-string-or-pattern; arglists ([re-string-or-pattern])
20:16blbrownChouser, but there isn't a javadoc tool, I guess I could write my own
20:30gnuvince_What tool do you guys use to profile Clojure code?
20:36blbrownThis is my first real clojure app, only like 800 lines, http://botnode.com/src/text_viewer_1.png
20:39gnuvince_I really ought to get a Java book to learn about Swing so that I could make interfaces for the (small) apps I write.
20:40Carkthere are tons of nice tutorials at sun
20:41blbrownI would use swt. I am done with swing
20:42Carkswing is no good ?
20:43blbrownCark, I don't think so, and SWT is so much cleaner and easier to work with. There are also plug and play widgets that come with SWT like a working web browser
20:44gnuvince_Is SWT shipped with the JRE?
20:44blbrownNope, Eclipse is based on SWT, so it is here. http://www.eclipse.org/swt/
20:45blbrownbut then again, I haven't tried swing with clojure, clojure may improve on swing
20:51lisppaste8gnuvince pasted "Does that look okay?" at http://paste.lisp.org/display/73836
21:08lisppaste8rhickey pasted "scope blocks" at http://paste.lisp.org/display/73838
21:09rhickeyio-scope has evolved into ^^
21:10rhickeygeneral system for resource management
21:10Chouserexits first, then succeeds/fails
21:10rhickeyreverse order of declaration
21:11Chouserwow
21:11rhickeyirrespective of cause
21:15antifuchsrhickey: wouldn't it make more sense to be by order of arguments?
21:15blbrownis that feature found in other languages
21:15rhickeyantifuchs: I don't think so
21:15antifuchsunix shells with their trap function/
21:15aperotteChouser: I saw your discussion on the google group about adding post-init to gen-class, has there been any more discussion on it?
21:16rhickeyblbrown: D has a similar feature, but you can't control the scopes, they are the nearest enclosing language-level block
21:16antifuchsrhickey: hm, why?
21:17aperotteChouser: I've come up against the same issue trying to use the restlets library and was wondering if there was a way around the issue
21:18antifuchsI think boa is the default for many things... it seems pretty exceptional to have stuff come out in reverse order sometimes
21:19rhickeyantifuchs: not sure what you mean by boa here, but most times resources are freed in reverse order
21:20antifuchsah, that's true
21:20rhickeyin any case, you have control as it is based on the order of calls to when-scope
21:21antifuchsI'm used to resources getting freed through stacking of with- forms, but as a cleanup thing it does make sense.
21:23rhickeystacking with-s unwinds in reverse too
21:37rhickeyscope names ok?
21:38danlarkinI think so
21:38danlarkinso in your example, you're just putting a few when-scopes in a function for convenience, right? There's no semantics involved with that?
21:39danlarkinor.. not semantics, I mean it could just be in the body of the (scope) form?
21:40rhickeydanlarkin: just trying to demonstrate it is a truly dynamic scope, not just lexical
21:40danlarkinmmhmm
21:41rhickeythe different when-scopes happen due to different scope termination situations
21:42rhickey:exits matches any, :fails matches exits w/exception, :succeeds matches exit normally
21:43rhickeywhen-scope not within any scope throws exception
21:43rhickeyso nested contexts can create, register, and return resources knowing they will get cleaned up
21:46danlarkinI like this
21:50hiredmanvery useful
21:57blbrownYou guys might be able to help me. In lisp/clojure, I think of 'macros' as DEFINE's in C (#define ABC 123), a syntax for replacing values in code. Is this true or is it a lot more complex.
21:58apage43a lot more complex
22:00apage43see http://clojure.org/macros
22:00Chouserwell, it's the same core idea, though
22:01apage43Chouser: well, far from a "#define ABC 123". I don't think i've ever seen a lisp macro used to store a constant =P
22:01Chousertwo big differences are that #define produces text instead of structured code/data (s-exprs). The other is that lisp macros can use any *function* defined earlier, not just other macros.
22:02Chouserapage43: the #define rabbit hole goes deeper than that, though. :-)
22:02apage43of course
22:02apage43but #define is still not near as powerful
22:03apage43also complex #define's are terrrrible to debug
22:04Chouseryes, of course, that's all true.
22:05Chouserbut it's not a completely unrelated concept, like for example Excel macros.
22:15Chouserand I've used #define to add control structures, just like lisp macros. 'foreach'
22:15Chouserbut yes, terrible
22:20danlarkinChouser: oh jeez. that's awful
22:26blbrownlook at the linux kernel source...that is some scary use of macros
22:58blbrownI also never totally understood when you should write a macro and when just a function would do
22:59danlarkinin lisps?
23:00Carkyou mean in the linux kernel or using clojure ?
23:00danlarkinyou only need a macro if you want to control evaluation of forms
23:00blbrownin lisps
23:00Carkdanlarkin : nope, you can do this with high order functions
23:01blbrowndanlarkin, I think I see what you are saying. When I need more than a <function-call args>?
23:01Carkyou need macros to make your code pretty, that's about it
23:01danlarkinCark: functions can't control evaluation of their arguments
23:01durka42or to avoid repetition
23:02Cark(defn my-if [cond-fn true-fn false-fn] ....)
23:02Carkthat's what i mean
23:02Carkof course that's ugly
23:02Carkthough not that ugly with clojure
23:02durka42true, but what about lazy and/or
23:03Carksame thing
23:03durka42short-circuiting is the word i was looking for
23:03durka42oh if you wrap everything in a #() i suppose
23:03Cark(defn my-or [& list-of-predicate-functions] ...)
23:03Carkso really, maccros are only there to make it pretty
23:04danlarkinCark: (defn my-if [cond-fn true-fn false-fn] ....) doesn't control evaluation of arguments, cond-fn, true-fn and false-fn will all be evaluated. They won't be /executed/ unless you call them, but they're still evaluated
23:04durka42if you want to use things that won't resolve as symbols you need a macro
23:04apage43Cark: somewhat. the my-or and my-if would a, have to take -functions-, which means using them uses more stack space than the macro version
23:05Carkhehe sure, but that's implementation detail
23:07Carki beleive in some smalltalks that's how if is defined
23:09Carkdanlarkin: the point is i can still call (if #(identity true) #(identity 1) #(/ 1 0))
23:09Carki mean "my-if"
23:09danlarkinThere are things macros can do that functions cannot, and those things rely on delaying (or canceling) evaluation of arguments. Sure, "if" could be written with functions, but that would be a different language
23:10Carkof course noone would rewrite an if function, that's only an exemple of controling evaluation using high order functions
23:11Carkwhat's really bad in this my-if thing, is that it's leaking implementation detail
23:11Carkthat's why you want a macro
23:11Carkso the user don't need to know oh that works
23:11Cark*how
23:12Chouserbut users generally do need to know if the thing they're calling is a macro or a function
23:12Carkahh true
23:12apage43eh, not as such, they just need to know what the thing they're calling returns
23:12Chousermacros can do things like capture names, which fns cannot
23:13Chouserapage43: no, the fact that 'and' short-circuits is sometimes important.
23:13Chousermacros can do things at compile-time, which fns cannot. Clojure uses this for 'proxy', for example.
23:13Carkchouser : going purely functional you wouldn't need to capture names at all
23:14blbrownthis is a good discussion, someone save it.
23:14durka42clojurebot: logs
23:14clojurebotlogs is http://clojure-log.n01se.net/
23:14Carkchouser : hum you could use function calls directly in your source file, and call the api
23:14Carklike creating namespaces and such
23:15Carkof course macros are nice don't get me wrong !
23:15durka42that might be difficult without the . macro
23:15Chouserbut usages of 'proxy' aren't at the top level, so if it were a function it couldn't do anything at compile time.
23:16Carkright, though that's specific to clojure
23:17apage43anyway
23:17apage43the end purpose of macros is to allow you to write -less code-
23:17apage43which they can do in ways functions cannot
23:17Carkand prettier !
23:18ChouserI'm pretty sure name capture would still be useful in a pure functional language.
23:18Carkwell you do it this way : (my-hf (fn [captured-name] ....))
23:19ChouserCark: ah, you're right. Good point.
23:20Carki couple months ago i wanted to have the prog1 macro included in clojure
23:21Carkthen some person (andre thieme?) reminded me that this could be done with a function
23:23Chouserso yes, macros are for simplifing code that cannot be simplified sufficiently using a function.
23:25Carknice flamme war on c.l.l ...thei're talking a bit about clojure and implementing lisp on the jvm
23:27gnuvince_lik?
23:27gnuvince_link
23:28Carkhum i'm reading from a newsgroup reader =/ ... it's "Making lisp popular - can it be done" in comp.lang.lisp
23:29durka42http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/be5630a07e123df2/3e06f2cb3734c9ab?lnk=gst&amp;q=making+lisp+popular#3e06f2cb3734c9ab
23:29durka42bah, cut before &q to lose the highlighting
23:33danlarkinjeez
23:33danlarkinthese people are _angry_
23:36Carkthat's c.l.l for you =)
23:36Carkstill they're very helpfull
23:37Cark...usually