Re: [?] Adding my own function to clojure.core namespace

2018-02-27 Thread Kurt Harriger
You might also have a look at a library called vinyasa
 

> https://github.com/ardumont/vinyasa
>

You can can add it to your lein profile to copy functions into clojure.core 
and prefix them.  
The prefix makes it very clear that these are not part of standard 
clojure.core. 

(inject 'clojure.core '>> '[[clojure.repl doc [source source]]]) 

;; => will create the var #'clojure.core/>>doc and #'clojure.core/source
 


-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-27 Thread Colin Fleming
On 25 February 2018 at 23:42, Gary Fredericks 
wrote:

> For clojure (not cljs, yet) I proxy all the dev utilities I might want to
> use in a namespace called `.` so I can refer to it everywhere no matter
> what the local namespace setup is: https://github.com/
> gfredericks/dot-slash-2
>

Note that the reader doc (https://clojure.org/reference/reader) says that
"Symbols beginning or ending with '.' are reserved by Clojure". It's not
enforced of course, but it might break things. It might be a good idea to
use some other single char prefix.




> On Sunday, February 25, 2018 at 11:45:41 AM UTC-6, Philos Kim wrote:
>>
>> I have another question. Debux library supports ClojureScript as well.
>> Similarly, I want to add my own function or macro to cljs.core as in
>> Clojure. Can I use the same strategy in ClojureScript as in Clojure if I
>> use it in the  ClojureScript source code, not in REPL?
>
> --
> 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 patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Gary Fredericks
For clojure (not cljs, yet) I proxy all the dev utilities I might want to 
use in a namespace called `.` so I can refer to it everywhere no matter 
what the local namespace setup is: 
https://github.com/gfredericks/dot-slash-2

On Sunday, February 25, 2018 at 11:45:41 AM UTC-6, Philos Kim wrote:
>
> I have another question. Debux library supports ClojureScript as well. 
> Similarly, I want to add my own function or macro to cljs.core as in 
> Clojure. Can I use the same strategy in ClojureScript as in Clojure if I 
> use it in the  ClojureScript source code, not in REPL?

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Philos Kim
I have another question. Debux library supports ClojureScript as well. 
Similarly, I want to add my own function or macro to cljs.core as in Clojure. 
Can I use the same strategy in ClojureScript as in Clojure if I use it in the  
ClojureScript source code, not in REPL?

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread James Reeves
On 25 February 2018 at 12:01, Philos Kim  wrote:

> I know it is not desirable but it is sometimes needed, especially in my
> case.
>
> For example , I wrote debux ( https://github.com/philoskim/debux )
> library. I want to use it only in development, not in production. If I
> 'require' debux in source code to use it in development, I have to remove
> it in the source code manually in production.
>

The normal solution to this is to have a development namespace and a
production namespace that serve as entry points for your application.
During development you load in the dev namespace, and in production the
prod namespace will contain the -main function that starts your application.

You can omit the development namespace and anything it requires from the
production classpath when you compile the jar.

-- 
James Reeves
booleanknot.com

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Mikhail Gusarov
Hello Philos,

> For example , I wrote debux ( https://github.com/philoskim/debux ) 
> library. I want to use it only in development, not in production. If I 
> 'require' debux in source code to use it in development, I have to 
> remove it in the source code manually in production.

Do you intend to use this library from REPL or from the code itself?
If former, you can add the library to Leiningen (or whatever) REPL environment.
If latter, how do you enable/disable the debugging code in production? You can
use the same way for requiring/not requiring library.

> I tested your recommendation in REPL and it worked. However could you 
> tell me about how I can implement it in source code form, not in REPL?

There is no difference.

Regards,
Mikhail.

On Sun, 25 Feb 2018, at 13:01, Philos Kim wrote:
> Thanks both of you!
> 
> I know it is not desirable but it is sometimes needed, especially in my case.
> 
> For example , I wrote debux ( https://github.com/philoskim/debux ) 
> library. I want to use it only in development, not in production. If I 
> 'require' debux in source code to use it in development, I have to 
> remove it in the source code manually in production.
> 
> I tested your recommendation in REPL and it worked. However could you 
> tell me about how I can implement it in source code form, not in REPL?
> 
> -- 
> 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 patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google 
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Philos Kim
Thanks both of you!

I know it is not desirable but it is sometimes needed, especially in my case.

For example , I wrote debux ( https://github.com/philoskim/debux ) 
library. I want to use it only in development, not in production. If I 
'require' debux in source code to use it in development, I have to remove it in 
the source code manually in production.

I tested your recommendation in REPL and it worked. However could you tell me 
about how I can implement it in source code form, not in REPL?

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-24 Thread Andy Fingerhut
I would echo the question "is it truly a good idea?"

You can do it, but typing a single :require clause in an ns form once, and
then copying and pasting to other places that you use functions defined in
that namespace, is likely to be less time-consuming in the long run.

Andy

On Sat, Feb 24, 2018 at 10:08 PM, Philos Kim  wrote:

> Is there any way to add my own function to clojure.core namespace? Because
> I want to use that function globally without 'require' or 'use'.
>
> Thanks in advance.
>
> --
> 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 patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-24 Thread Mikhail Gusarov
Hello Philos,

It's no different to adding a function to any other namespace:

% clj
Clojure 1.9.0
user=> (ns clojure.core)
nil
clojure.core=> (defn foobar [x] (str "foobar " x))
#'clojure.core/foobar
clojure.core=> (ns user)
nil
user=> (foobar "12")
"foobar 12"
user=> foobar
#object[clojure.core$foobar 0x43b6123e "clojure.core$foobar@43b6123e"]
user=>

However is it truly a good idea?

On Sun, 25 Feb 2018, at 07:08, Philos Kim wrote:
> Is there any way to add my own function to clojure.core namespace? 
> Because I want to use that function globally without 'require' or 'use'. 
> 
> Thanks in advance.
> 
> -- 
> 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 patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google 
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] Adding my own function to clojure.core namespace

2018-02-24 Thread Philos Kim
Is there any way to add my own function to clojure.core namespace? Because I 
want to use that function globally without 'require' or 'use'. 

Thanks in advance.

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.