Extra optional attr-map argument on defn... why?

2021-08-08 Thread Robert Levy
In a private chat (I will not expose their names, but they may feel free to identify themselves in this thread) someone posed a question: Anyone know why the multi-arity version of `defn` takes an extra optional `attr-map?` argument? https://github.com/clojure/clojure/blob/clojure-1.10.1/src/clj

Re: [ANN] defn-spec, define your specs inline with your function

2019-04-01 Thread Alan Thompson
Looks interesting! Definitely need to check this out. Alan On Sun, Mar 31, 2019 at 12:44 AM Daniel Compton < daniel.compton.li...@gmail.com> wrote: > Hi folks > > I've released 0.1.0 of defn-spec > <https://github.com/danielcompton/defn-spec>, a library that le

[ANN] defn-spec, define your specs inline with your function

2019-03-31 Thread Daniel Compton
Hi folks I've released 0.1.0 of defn-spec <https://github.com/danielcompton/defn-spec>, a library that lets you define your function specs inline with your function definitions. A quick example, defn-spec lets you write: (ds/defn to-zoned-dt :- ::zoned-date-time [instant :- ::inst

Re: defn with inline specs?

2017-06-19 Thread Alex Miller
about how you can grow the function while retaining the spec. Additionally, if I think about the changes that would be needed in the defn macro to make this happen they seem pretty gross. :) On Monday, June 19, 2017 at 6:06:10 PM UTC-5, Daniel Compton wrote: > > > We think there is a lot

Re: defn with inline specs?

2017-06-19 Thread Daniel Compton
and readable, and avoids typos between the defn name and the fdef name. On Tue, Jun 20, 2017 at 10:23 AM Alex Miller wrote: > No, we don't plan to add that. We think there is a lot of value in having > them independent. > > Rather than add it to the guide, I would prefer to add a s

defn with inline specs?

2017-06-19 Thread Alex Miller
No, we don't plan to add that. We think there is a lot of value in having them independent. Rather than add it to the guide, I would prefer to add a section to the FAQ page. I've been to do so, but haven't gotten around to it yet. -- You received this message because you are subscribed to the

defn with inline specs?

2017-06-19 Thread Daniel Compton
Currently I don't think it's possible to include a spec inline with a function definition. If you want to spec a function, it needs to come afterwards in an s/fdef. Is it planned for defn to have an extension to allow inline specs, similar to how pre and postconditions are defined

RE: How to Create Clojure `defn` Functions automatically?

2017-05-14 Thread Phillip Lord
m [clojure@googlegroups.com] on behalf of Timothy Baldridge [tbaldri...@gmail.com] Sent: 14 May 2017 00:04 To: clojure@googlegroups.com Subject: Re: How to Create Clojure `defn` Functions automatically? Okay, so I've read these SO articles about 4 times now, and I finally think I'm startin

Re: How to Create Clojure `defn` Functions automatically?

2017-05-13 Thread Alan Thompson
tions> >> was incomplete for the new question and I was trying to fill in the missing >> parts. >> >> >> >> On Sat, May 13, 2017 at 3:40 PM, Timothy Baldridge >> wrote: >> >>> Sorry, but this use of intern is a pointless. What does in

Re: How to Create Clojure `defn` Functions automatically?

2017-05-13 Thread Timothy Baldridge
-to-generate-functions> > was incomplete for the new question and I was trying to fill in the missing > parts. > > > > On Sat, May 13, 2017 at 3:40 PM, Timothy Baldridge > wrote: > >> Sorry, but this use of intern is a pointless. What does intern give you &g

Re: How to Create Clojure `defn` Functions automatically?

2017-05-13 Thread Alan Thompson
e: > Sorry, but this use of intern is a pointless. What does intern give you > that a let over a defn doesn't? > > On Sat, May 13, 2017 at 4:37 PM, Alan Thompson wrote: > >> If anyone is interested, I cleaned up the question to (hopefully) make it >> clearer, as w

Re: How to Create Clojure `defn` Functions automatically?

2017-05-13 Thread Timothy Baldridge
Sorry, but this use of intern is a pointless. What does intern give you that a let over a defn doesn't? On Sat, May 13, 2017 at 4:37 PM, Alan Thompson wrote: > If anyone is interested, I cleaned up the question to (hopefully) make it > clearer, as well as adding the macro-call

Re: How to Create Clojure `defn` Functions automatically?

2017-05-13 Thread Alan Thompson
functions. Here is the re-worked version: http://stackoverflow.com/questions/43958471/how-to-create-clojure-defn-functions-automatically-without-macros/ Alan On Thu, May 11, 2017 at 10:15 AM, Alan Thompson wrote: > Actually someone else wrote the original CLJS question (1): >

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Alan Thompson
lback stuff, and may have oversimplified. Since question was closed as being a "duplicate" (in error, I think), I couldn't answer there and posed the Q&A style answer separately at (3): http://stackoverflow.com/questions/43904628/how-to-create-clojure-defn-functions-automatically

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Timothy Baldridge
t;> What's wrong with (foo :able) => "Adelicious!" and (:able foo) => >>>> "Adelicious!"? >>>> >>>> >>>> On Thursday, May 11, 2017 at 9:20:19 AM UTC+2, Alan Thompson wrote: >>>>> >>>>> A r

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Alan Thompson
>>>> >>>> A recent question on StackOverflow raised the question of the best way >>>> to automatically generate functions. Suppose you want to automate the >>>> creation of code like this: >>>> >>>> >>>> >>>> (def foo &

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Alan Thompson
on of the best way >>> to automatically generate functions. Suppose you want to automate the >>> creation of code like this: >>> >>> >>> >>> (def foo >>> {:able"Adelicious!" >>>:baker "Barbrallicious!&

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Alan Thompson
tomatically generate functions. Suppose you want to automate the creation >> of code like this: >> >> >> >> (def foo >> {:able"Adelicious!" >>:baker "Barbrallicious!" >>:charlie "Charlizable"}) >> (def

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Dragan Djuric
of code like this: >>> >>> >>> >>> (def foo >>> {:able"Adelicious!" >>>:baker "Barbrallicious!" >>>:charlie "Charlizable"}) >>> (def bar >>> {:able"Apple" >>>

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Timothy Baldridge
raised the question of the best way to >> automatically generate functions. Suppose you want to automate the creation >> of code like this: >> >> >> >> (def foo >> {:able"Adelicious!" >>:baker "Barbrallicious!" >&g

Re: How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Dragan Djuric
ctions. Suppose you want to automate the creation > of code like this: > > > > (def foo > {:able"Adelicious!" >:baker "Barbrallicious!" >:charlie "Charlizable"}) > (def bar > {:able"Apple" >:bak

How to Create Clojure `defn` Functions automatically?

2017-05-11 Thread Alan Thompson
}) (def bar {:able"Apple" :baker "Berry" :charlie "Kumquat"}) (defn manual-my-foo [item] (get foo item)) (defn manual-my-bar [item] (get bar item)) (manual-my-foo :able) => "Adelicious!" (manual-my-bar :charlie) => "Kumquat" You c

[ANN] defn podcast episode #11 with Alex Miller

2016-10-06 Thread Vijay Kiran
Hello everyone, Episode 11 of defn is now available on the Interwebs. You can listen to it on SoundCloud: https://soundcloud.com/defn-771544745/episode-11-alex-miller or subscribe via iTunes https://itunes.apple.com/us/podcast/defn/id1114899563 The show notes are available on https

Re: [ANN] defn Podcast Episode #9 Onyx

2016-09-12 Thread Bradley Pitts
he new episode of defn podcast is now available, Onyx with Michael > Drogalis and Lucas Bradstreet! You can listen to it on SoundCloud[1] or via > itunes[1] > > We'd really appreciate your comments or feedback :) > > Enjoy, > Ray & Vijay > > > [1] https://

Re: [ANN] defn Podcast Episode #9 Onyx

2016-09-07 Thread William Swaney
Cool, really looking forward to listening to this. Thanks for the work, guys. Bill On Tuesday, September 6, 2016 at 11:24:31 PM UTC-7, Vijay Kiran wrote: > > Hello Everyone, > > The new episode of defn podcast is now available, Onyx with Michael > Drogalis and Lucas Brad

[ANN] defn Podcast Episode #9 Onyx

2016-09-06 Thread Vijay Kiran
Hello Everyone, The new episode of defn podcast is now available, Onyx with Michael Drogalis and Lucas Bradstreet! You can listen to it on SoundCloud[1] or via itunes[1] We'd really appreciate your comments or feedback :) Enjoy, Ray & Vijay [1] https://defn.audio/2016/09/06/episo

[ANN] defn podcast ep.5 : Hoplon Special with Micha Niskin :)

2016-07-14 Thread Vijay Kiran
Hi Everyone, We just published new episode of defn with special guest Micha Niskin discussing Hoplon. It is available for your listening pleasure on SoundCloud: https://soundcloud.com/defn-771544745/05-hoplon-special-with-micha-niskin also available via iTunes. Regards, Vijay & Ray h

[ANN] defn Podcast Episode #4 Immutable Persistent Collections

2016-06-30 Thread Vijay Kiran
Hello Everyone, We published the Episode #4 of defn podcast, the topic of this episode is immutable persistent collections. It is available on SoundCloud for your listening pleasure: https://soundcloud.com/defn-771544745/defn-04-immutable-persistent-collections :) If you happen to listen to

Re: [ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-16 Thread Mond Ray
13:42:25 UTC+5:30, Vijay Kiran wrote: >> >> Hello Everyone! >> >> We published the third episode of defn yesterday in which we take a tour >> of REPLs in Clojure Land. >> >> We are very grateful to Mike Fikes <https://twitter.com/mfikes> &g

Re: [ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-16 Thread Ashish Negi
Thanks for the podcast.. I would highly appreciate one on Machine Learning in Clojure. On Tuesday, 14 June 2016 13:42:25 UTC+5:30, Vijay Kiran wrote: > > Hello Everyone! > > We published the third episode of defn yesterday in which we take a tour > of REPLs in Clojure Land.

Re: [ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-16 Thread Mond Ray
Thanks for listening Jason and for taking the time to give us feedback. To echo Vijay's comments, we will be happy to have a 'follow-up' section in the podcast to correct mistakes and omissions. I really need to work on a defn related pun to end such emails but for now, I h

Re: [ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-16 Thread Vijay Kiran
On Tuesday, June 14, 2016 at 4:12:25 AM UTC-4, Vijay Kiran wrote: >> >> Hello Everyone! >> >> We published the third episode of defn yesterday in which we take a tour >> of REPLs in Clojure Land. >> >> We are very grateful to Mike Fikes <https://twitter.

Re: [ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-14 Thread Jason Gilman
x27;re writing. Another one in that vein is Gorilla REPL which inspired some of the visualization aspects of Proto REPL. Thanks, Jason Gilman On Tuesday, June 14, 2016 at 4:12:25 AM UTC-4, Vijay Kiran wrote: > > Hello Everyone! > > We published the third episode of defn yesterday in

[ANN] defn podcast ep.3 : A tour of REPLs feat. Mike Fikes :)

2016-06-14 Thread Vijay Kiran
Hello Everyone! We published the third episode of defn yesterday in which we take a tour of REPLs in Clojure Land. We are very grateful to Mike Fikes <https://twitter.com/mfikes> (Planck/Replete/Ambly fame) - who joined us on the podcast to share his experience. We would love to hea

Re: [ANN] New Clojure Podcast: defn

2016-05-23 Thread Terje Dahl
hed our first episode and plan to release a new one every two > weeks. It is available on iTunes > https://itunes.apple.com/podcast/defn/id1114899563 and SoundCloud: > https://soundcloud.com/defn-771544745 > > You can also get the RSS feed via > http://feeds.soundcloud.com/user

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread Mond Ray
Thanks Ashish - that's really good feedback. We will improve the notes along the lines that you request. On Friday, 20 May 2016 12:02:05 UTC+2, Ashish Negi wrote: > > The notes has : > ``` > Credits: > > *Music:* Thanks to the very talented *ptzery* for the permitting us to > use his music on t

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread Mond Ray
om/gb/podcast/wired.co.uk-wired-uk-podcast/id404893471?mt=2 > > > For your podcast, there is not much description of the content of the > episode: > > https://itunes.apple.com/podcast/defn/id1114899563 > > There is also no description of the individual episode when you ha

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread 'Alan Forrester' via Clojure
: https://itunes.apple.com/gb/podcast/wired.co.uk-wired-uk-podcast/id404893471?mt=2 For your podcast, there is not much description of the content of the episode: https://itunes.apple.com/podcast/defn/id1114899563 There is also no description of the individual episode when you have downloaded

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread Ashish Negi
The notes has : ``` Credits: *Music:* Thanks to the very talented *ptzery* for the permitting us to use his music on the opening and closing of the podcast. This track is Melon Hamburger. You can hear more on his SoundCloud . *Audio:* Thanks to the audio wizard

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread Vijay Kiran
> We published our first episode and plan to release a new one every two >> weeks. It is available on iTunes >> https://itunes.apple.com/podcast/defn/id1114899563 and SoundCloud: >> https://soundcloud.com/defn-771544745 >> >> You can also get the RSS feed via &g

Re: [ANN] New Clojure Podcast: defn

2016-05-20 Thread Ashish Negi
fn.audio > > We published our first episode and plan to release a new one every two > weeks. It is available on iTunes > https://itunes.apple.com/podcast/defn/id1114899563 and SoundCloud: > https://soundcloud.com/defn-771544745 > > You can also get the RSS feed via

Re: [ANN] New Clojure Podcast: defn

2016-05-19 Thread Mark Derricutt
On 19 May 2016, at 17:43, Vijay Kiran wrote: > Just wanted to let you know that we started a new podcast about Clojure:  > [https://defn.audio](https://defn.audio) +2 - enjoyed the first episode. Congrats. -- Mark Derricutt http://www.theoryinpractice.net http://www.chaliceofblood.net http://p

[ANN] New Clojure Podcast: defn

2016-05-18 Thread Vijay Kiran
Hello Everyone, Just wanted to let you know that we started a new podcast about Clojure: https://defn.audio We published our first episode and plan to release a new one every two weeks. It is available on iTunes https://itunes.apple.com/podcast/defn/id1114899563 and SoundCloud: https

Re: Define new defn, lein uberjar succeeds to compile but lein run fails

2015-11-25 Thread Benjamin R. Haskell
It sounds like you're looking for refer-clojure: https://clojuredocs.org/clojure.core/refer-clojure E.g., for your project: (ns mw.mwm (:require [clojure.pprint :as pp] [clojure.walk :as walk]) (:refer-clojure :exclude [defn]) (:gen-class)) Tested in a fork: https://githu

Re: Define new defn, lein uberjar succeeds to compile but lein run fails

2015-11-25 Thread mattias w
I moved my own definition of defn to a separate project, and then it works. It seems you cannot redefine defn within the same project it is used. Den fredag 13 november 2015 kl. 13:46:56 UTC+1 skrev mattias w: > > I defined my own defn in the namespace mwm. > > > My new code

Define new defn, lein uberjar succeeds to compile but lein run fails

2015-11-13 Thread mattias w
I defined my own defn in the namespace mwm. My new code looks like this (mwm/defn foo [x] ...) Everything was fine as long as it was called defn2, but after renaming it to defn and refering to the original defn using clojure.core/defn, only "lein uberjar" works. When I run

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-08 Thread Andy Fingerhut
you have a link to the discussion? Is this really the reasoning? > > I find it insufficient, because there aren't many defs supporting private : > > def, defn, defmacro and definline if I am remembering correctly. > > I am kind of tired of writing def ^:private. def- woul

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-08 Thread Leon Grapenthin
Do you have a link to the discussion? Is this really the reasoning? I find it insufficient, because there aren't many defs supporting private : def, defn, defmacro and definline if I am remembering correctly. I am kind of tired of writing def ^:private. def- would really be nice to

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-08 Thread Stig Brautaset
Hi Herwig, On Thursday, 7 May 2015 15:36:44 UTC+1, Herwig Hochleitner wrote: > > 2015-05-07 16:12 GMT+02:00 Stig Brautaset >: > >> Is it because the def form can also be ^:dynamic? >> > Hm, cognitect turned it down, because basically "if you go down this road, > why stop with def- ? and before y

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-07 Thread adrian . medina
macro is evaluated that form is no longer present. Check out the source for defn- (you can find it in a REPL by calling (clojure.repl/source defn-) (defmacro defn- "same as defn, yielding non-public def" {:added "1.0"} [name & decls] (list* `defn (with-meta name (as

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-07 Thread Herwig Hochleitner
2015-05-07 16:12 GMT+02:00 Stig Brautaset : > Is it because the def form can also be ^:dynamic? > Hm, cognitect turned it down, because basically "if you go down this road, why stop with def- ? and before you know, you've got a core namespace full of def*-" > At any rate, I did an attempt at my f

Re: Why (defn- ...) but (def ^:private? ...)

2015-05-07 Thread Colin Yates
a macro? > > (defmacro def- > "Why (defn- private-fn ...) but (def ^:private var ...)?" > [sym & body] > `(def ^:private ~sym ~@body)) > > ;; => #'user/def- > user> (macroexpand '(def- blah "foo bar quux")) > ;; => (def b

Why (defn- ...) but (def ^:private? ...)

2015-05-07 Thread Stig Brautaset
Is it because the def form can also be ^:dynamic? At any rate, I did an attempt at my first macro to create a (def- ...) form, but it doesn't seem to work. Can you not attach metadata in a macro? (defmacro def- "Why (defn- private-fn ...) but (def ^:private var ...)?" [sym

Re: defn inside defn

2014-11-15 Thread Fluid Dynamics
On Saturday, November 15, 2014 11:31:50 AM UTC-5, Udayakumar Rayala wrote: > > twice> > > Hi, > > Is it idiomatic to have defn inside defn? eastwood throws def-in-def > warning when I have the following code: > > (defn double-square [y] > (defn square [x

Re: defn inside defn

2014-11-15 Thread Andy Fingerhut
x27;s inside other def's are _not_ local. In your example, you will find after defn'ing double-square with the defn square inside that later you can call not only double-square from other functions, but also square, because the defn makes it globally visible (in that namespace, and any oth

Re: defn inside defn

2014-11-15 Thread David Nolen
Not idiomatic. defn is always top level. David On Sat, Nov 15, 2014 at 11:31 AM, Udayakumar Rayala wrote: > twice> > > Hi, > > Is it idiomatic to have defn inside defn? eastwood throws def-in-def warning > when I have the following code: > > (defn double-square [y

defn inside defn

2014-11-15 Thread Udayakumar Rayala
Hi, Is it idiomatic to have defn inside defn? eastwood throws def-in-def warning when I have the following code: (defn double-square [y] (defn square [x] (* x x)) (+ (square y) (square y))) The above code is a simplified example to show the problem. In the above case, square

Re: destructuring help: `(let [{:keys [...]} ...]` in a `defn` vs in a `let`

2014-08-27 Thread James Reeves
Apparently a list can be destructured as a map, but a vector cannot. The "& args" syntax returns the result as a list, not a vector. - James On 27 August 2014 19:20, John Gabriele wrote: > Why is it that although this works: > > ~~~clojure > (defn foo [& args]

Re: destructuring help: `(let [{:keys [...]} ...]` in a `defn` vs in a `let`

2014-08-27 Thread Ben Wolfson
ke this: > (let [{a 0} [:a 1]] a) :a ... confusing though it is. On Wed, Aug 27, 2014 at 11:20 AM, John Gabriele wrote: > Why is it that although this works: > > ~~~clojure > (defn foo [& args] (let [{:keys [a b]} args] (str a \~ b))) > ;;=> #'some-app.

Re: destructuring help: `(let [{:keys [...]} ...]` in a `defn` vs in a `let`

2014-08-27 Thread Ben Wolfson
... the other half of the answer being that when you have rest args with (defn foo [& args] ...), "args" is bound to a seq. On Wed, Aug 27, 2014 at 11:27 AM, Ben Wolfson wrote: > The reason is that in the macroexpansion of "let", map-based destructuring > has a s

destructuring help: `(let [{:keys [...]} ...]` in a `defn` vs in a `let`

2014-08-27 Thread John Gabriele
Why is it that although this works: ~~~clojure (defn foo [& args] (let [{:keys [a b]} args] (str a \~ b))) ;;=> #'some-app.core/foo (foo :a 1 :b 2) ;;=> "1~2" ~~~ this does not: ~~~clojure (let [{:keys [a b]} [:a 1 :b 2 :c 3]] (str a \~ b)) ;;=> "~" ~~~ ?

Re: How to unit test (defn-) functions?

2014-06-14 Thread rarous
Always test private functions through public ones. They have to use them. Private stuff should appear during refactoring phase. On Thursday, June 12, 2014 10:44:21 AM UTC+2, Hussein B. wrote: > > Hi, > > I like to use (defn-) when it comes to internal implementation functions. >

Re: How to unit test (defn-) functions?

2014-06-12 Thread Sean Corfield
On Thu, Jun 12, 2014 at 7:33 AM, Timothy Baldridge wrote: > I say this too many times on this list, but I'll say it again. The best way > to test defn- functions is to never use defn- in the first place. Instead > move implementation functions into an internal namespace that way

Re: How to unit test (defn-) functions?

2014-06-12 Thread Timothy Baldridge
There are 6 defn-'s in there? Rich must have wrote that code :-P . But yes, defn- is mostly used in clojure.core and other such libraries for functions that are created to simplify other functions. And I would probably never test those. Even then I would caution about using defn- too mu

Re: How to unit test (defn-) functions?

2014-06-12 Thread J Irving
Hey Timothy So I honestly don't mean to be a smart ass, but there are 6 defn- functions in clojure.core.async - how do you test those? Or are they just considered internals to other public functions? cheers, J On Thu, Jun 12, 2014 at 10:33 AM, Timothy Baldridge wrote: > I say this

Re: How to unit test (defn-) functions?

2014-06-12 Thread Timothy Baldridge
I say this too many times on this list, but I'll say it again. The best way to test defn- functions is to never use defn- in the first place. Instead move implementation functions into an internal namespace that way they can be accessed if needed, but are out of the way of the public api. It

Re: How to unit test (defn-) functions?

2014-06-12 Thread mynomoto
You can use a macro. Look how on http://nakkaya.com/2009/11/18/unit-testing-in-clojure/ On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote: > > Hi, > > I like to use (defn-) when it comes to internal implementation functions. > But since they aren't exposed, h

Re: How to unit test (defn-) functions?

2014-06-12 Thread James Reeves
On 12 June 2014 09:44, Hussein B. wrote: > > I like to use (defn-) when it comes to internal implementation functions. > But since they aren't exposed, how to unit test them? > Generally speaking it's a bad idea to unit-test private functions (in any language), as they

Re: How to unit test (defn-) functions?

2014-06-12 Thread Ray Miller
On 12 June 2014 09:44, Hussein B. wrote: > Hi, > > I like to use (defn-) when it comes to internal implementation functions. > But since they aren't exposed, how to unit test them? > > Of course, I'm using Lein and clojure.test It feels like a bit of a hack,

How to unit test (defn-) functions?

2014-06-12 Thread Hussein B.
Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: A macro for writing defn-like macros?

2013-09-06 Thread Mark Addleman
That's cool. Thanks! On Fri, Sep 6, 2013 at 7:17 AM, Phillip Lord wrote: > > Mark writes: > > > I find the vast majority of the time I'm tempted to write a macro (yeah, > > yeah, I know the first rule of macro club), is to defn-like things. > > Writin

Re: A macro for writing defn-like macros?

2013-09-06 Thread Phillip Lord
Mark writes: > I find the vast majority of the time I'm tempted to write a macro (yeah, > yeah, I know the first rule of macro club), is to defn-like things. > Writing a defn-like macro to handle all the stuff defn does is pretty tough > so I end up writing a barebones t

Re: A macro for writing defn-like macros?

2013-09-03 Thread Konrad Hinsen
--On 3 septembre 2013 19:08:12 +0100 "Jim - FooBar();" wrote: understood what it does I can't figure out how to use it. Does anyone have an example usage? Let's suppose I want to define a DEFN macro that behaves exactly like defn...how would that go? I'm struggl

Re: A macro for writing defn-like macros?

2013-09-03 Thread Alex Baranosky
https://github.com/clojure/tools.macro/blob/master/src/main/clojure/clojure/tools/macro.clj#L275?? On Tue, Sep 3, 2013 at 9:01 AM, Mark wrote: > I find the vast majority of the time I'm tempted to write a macro (yeah, > yeah, I know the first rule of macro club), is to defn-

Re: A macro for writing defn-like macros?

2013-09-03 Thread Jim - FooBar();
Yes! I eventually figured it out...thanks Konrad :) Jim On 03/09/13 20:49, Konrad Hinsen wrote: --On 3 septembre 2013 19:08:12 +0100 "Jim - FooBar();" wrote: understood what it does I can't figure out how to use it. Does anyone have an example usage? Let's suppose I w

Re: A macro for writing defn-like macros?

2013-09-03 Thread Jim - FooBar();
I've been staring at this function for 20 minutes now (name-with-attributes)...I must be totally stupid but even though I 've understood what it does I can't figure out how to use it. Does anyone have an example usage? Let's suppose I want to define a DEFN macro that behav

Re: A macro for writing defn-like macros?

2013-09-03 Thread Ben Mabey
On 9/3/13 10:01 AM, Mark wrote: I find the vast majority of the time I'm tempted to write a macro (yeah, yeah, I know the first rule of macro club), is to defn-like things. Writing a defn-like macro to handle all the stuff defn does is pretty tough so I end up writing a barebones thing

Re: A macro for writing defn-like macros?

2013-09-03 Thread Ben Wolfson
> https://github.com/bwo/macroparser/blob/master/src/macroparser/functions.clj > > > > > On Tue, Sep 3, 2013 at 9:01 AM, Mark wrote: > >> I find the vast majority of the time I'm tempted to write a macro (yeah, >> yeah, I know the first rule of macro club),

Re: A macro for writing defn-like macros?

2013-09-03 Thread Ben Wolfson
macro club), is to defn-like things. > Writing a defn-like macro to handle all the stuff defn does is pretty tough > so I end up writing a barebones thing that doesn't support doc-string, > doesn't support multiple arities, and doesn't support metadata. I'm > wo

A macro for writing defn-like macros?

2013-09-03 Thread Mark
I find the vast majority of the time I'm tempted to write a macro (yeah, yeah, I know the first rule of macro club), is to defn-like things. Writing a defn-like macro to handle all the stuff defn does is pretty tough so I end up writing a barebones thing that doesn't support

Re: A strange syntax about clojure defn

2013-08-22 Thread ljcppunix
t;> Hi, >> I read source code about run-jetty, as such, at 01 line: "(defn >> #^Server run-jetty", >> what's mean "#^Server", could you give a explanation? thank you! >> >> 01(defn #^Server run-jetty >> 02 "Serve the given

Re: A strange syntax about clojure defn

2013-08-22 Thread Mikera
nt, but you should prefer the new style. On Thursday, 22 August 2013 16:50:42 UTC+8, ljcp...@gmail.com wrote: > > Hi, > I read source code about run-jetty, as such, at 01 line: "(defn > #^Server run-jetty", > what's mean "#^Server", could you g

A strange syntax about clojure defn

2013-08-22 Thread ljcppunix
Hi, I read source code about run-jetty, as such, at 01 line: "(defn #^Server run-jetty", what's mean "#^Server", could you give a explanation? thank you! 01(defn #^Server run-jetty 02 "Serve the given handler according to the options. 03 Options: 04:conf

Re: suggest to have defn/new/throw/etc.. allow evaluating ...maybe?

2013-02-25 Thread AtKaaZ
actor the heavy lifting out of the defmacro form > and test your logic there: > > (defn defdefn* [z] > (assert (symbol? z)) > `(defn ~z [x#] x#] > > (defmacro dedefn [zsym] > (defdefn* (eval zsym)) > > On Saturday, February 23, 2013 11:24:26 PM UTC-8, AtKaaZ wrote: &

Re: suggest to have defn/new/throw/etc.. allow evaluating ...maybe?

2013-02-24 Thread Tim Reinke
t;) This can get a little ugly if you need the eval form to capture variables. Alternatively, you can factor the heavy lifting out of the defmacro form and test your logic there: (defn defdefn* [z] (assert (symbol? z)) `(defn ~z [x#] x#] (defmacro dedefn [zsym] (defdefn* (eval zs

suggest to have defn/new/throw/etc.. allow evaluating ...maybe?

2013-02-23 Thread AtKaaZ
=> *(defn (symbol (str "a" "b")) [x] x)* IllegalArgumentException First argument to defn must be a symbol clojure.core/defn (core.clj:277) maybe allow ~ like this: =>* (defn ~(symbol (str "a" "b")) [x] x)* IllegalArgumentException First argum

Re: Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread Herwig Hochleitner
Thanks for your clarification! A few further thoughts: ClojureScript may one day be self-hosting but it's not a near term > goal given the desire to target the kinds of clients that run > JavaScript. Considering that the path to a self hosting clojure would probably start at clojurescript and t

Re: Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread David Nolen
On Thu, Sep 13, 2012 at 9:17 AM, Herwig Hochleitner wrote: > 2012/9/13 David Nolen >> >> >> That's how compiler macros are intended to work. > > > Great! So am I right with the notion, that clojure's defmacros are not > compiler macros and one would use the :inline meta key in clojure to achieve

Re: Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread Herwig Hochleitner
2012/9/13 David Nolen > > That's how compiler macros are intended to work. Great! So am I right with the notion, that clojure's defmacros are not compiler macros and one would use the :inline meta key in clojure to achieve the same effect? Supposing that I am, that means clojure has regular ma

Re: Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread David Nolen
On Thu, Sep 13, 2012 at 8:30 AM, Herwig Hochleitner wrote: > Hello, > > right now, this works in clojurescript: > > ;; in a file lib/fancy.cljs > (ns lib.fancy) > (defn fun [x] > [:runtime :fun x]) > > ;; in a file lib/fancy.clj > (ns lib.fancy) > (defma

Re: Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread Herwig Hochleitner
*typo correction*: the third block should be in a file app/core.*cljs* * * thanks -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be

Macros shadowing defn in clojurescript, akin to definiline

2012-09-13 Thread Herwig Hochleitner
Hello, right now, this works in clojurescript: ;; in a file lib/fancy.cljs (ns lib.fancy) (defn fun [x] [:runtime :fun x]) ;; in a file lib/fancy.clj (ns lib.fancy) (defmacro fun [x] [:precompiled :fun x]) ;; in a file app/core.clj (ns app.core (:require [lib.fancy :as fancy

Re: Cheap way to find function (defn) name using a macro?

2012-03-30 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 11:59 PM, Shantanu Kumar wrote: > The change needs to be least intrusive and doesn't justify exposing > more surface area than it should. It's a trade off. Injecting a version of defn that doesn't do anything different except make a new thing availabl

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Shantanu Kumar
On Mar 29, 11:46 pm, Cedric Greevey wrote: > On Thu, Mar 29, 2012 at 2:36 PM, Shantanu Kumar > > > > > > > > > > wrote: > >> 81  (defn foo [...] > >> 82    (let [x (compute-something ...)] > >> 83      (do-something x ...) > >&

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 2:36 PM, Shantanu Kumar wrote: >> 81  (defn foo [...] >> 82    (let [x (compute-something ...)] >> 83      (do-something x ...) >> 84      (calculate-whatever ...))) >> >> and you're able to edit lines 82, 83, and 84 but not line

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Shantanu Kumar
> 81  (defn foo [...] > 82    (let [x (compute-something ...)] > 83      (do-something x ...) > 84      (calculate-whatever ...))) > > and you're able to edit lines 82, 83, and 84 but not line 81 (or > whatever). But I can't see any plausible circumstance where th

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 11:35 AM, Shantanu Kumar wrote: > > > On Mar 29, 5:50 pm, Cedric Greevey wrote: >> On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar >> >> wrote: >> >> If you control the third line of: >> >> >> (defn foo [x y] >

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Shantanu Kumar
On Mar 29, 5:50 pm, Cedric Greevey wrote: > On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar > > wrote: > >> If you control the third line of: > > >> (defn foo [x y] > >>   (let [z (bar y (next x))] > >>     (println "Done in " (find

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Cedric Greevey
On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar wrote: >> If you control the third line of: >> >> (defn foo [x y] >>   (let [z (bar y (next x))] >>     (println "Done in " (find-name) ".") >>     (* 4 z (count x >> >> t

Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Sun Ning
Since you want to use the plain defn, what about thinking in a different way ? Write a macro like `with-function-name`, wraps the function call instead of the function definition. (defmacro with-function-name [fn-name args] ...) In clojure, because you can assign function to a var at any

  1   2   3   >