Clojure

load/ns/require/use overhaul

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Creating this ticket to describe various things people have wanted to change about how ns works:

Minimal needs

  1. there should be a primitive level of loading (presumably load) that just loads without question.
  2. the api should be unified across the ns and direct forms. No more keywords or quoting! So (use foo) not (use 'foo). This makes use et al macros, so there should also be new fn versions (maybe use*).

Other possibilities to discuss.

  1. Feature addressing the :like and :clone ideas from http://onclojure.com/2010/02/17/managing-namespaces/. I think I would prefer a single new option :clone which allows :only and :exclude features as subspecifiers.
  2. Convenience fn to unmap all names in a namespace?

Activity

Hide
Paudi Moriarty added a comment -

Permit tools to read the "ns" declaration and statically determine the dependencies of a namespace, without evaluating any code.

This would be great for building OSGi bundles where Bnd is currently not much help.

Show
Paudi Moriarty added a comment -
Permit tools to read the "ns" declaration and statically determine the dependencies of a namespace, without evaluating any code.
This would be great for building OSGi bundles where Bnd is currently not much help.
Hide
Stuart Sierra added a comment -

Further requests:

Permit tools to read the "ns" declaration and statically determine the dependencies of a namespace, without evaluating any code.

Show
Stuart Sierra added a comment - Further requests: Permit tools to read the "ns" declaration and statically determine the dependencies of a namespace, without evaluating any code.
Hide
Assembla Importer added a comment -

stuart.sierra said: My requests:

1. If writing macros that do not evaluate their arguments, provide function versions that do evaluate their arguments.

2. Do not support prefix lists for loading Clojure namespaces. It's hard to parse with external tools.

3. Do not conflate importing Java classes with loading Clojure namespaces. They are fundamentally different operations with different semantics.

I have implemented some ideas in a macro called "need" at http://github.com/stuartsierra/need

Show
Assembla Importer added a comment - stuart.sierra said: My requests: 1. If writing macros that do not evaluate their arguments, provide function versions that do evaluate their arguments. 2. Do not support prefix lists for loading Clojure namespaces. It's hard to parse with external tools. 3. Do not conflate importing Java classes with loading Clojure namespaces. They are fundamentally different operations with different semantics. I have implemented some ideas in a macro called "need" at http://github.com/stuartsierra/need
Hide
Assembla Importer added a comment -

stu said: Suggestions from Volkan Yazici:

Hi,

I saw your "load/ns/require/use overhaul" ticket[1] and would like to
ask for a few extra overhaulings. I have a project called retop, and
here is its file hiearachy:

tr/edu/bilkent/cs/retop.clj
tr/edu/bilkent/cs/retop/km.clj
tr/edu/bilkent/cs/retop/graph.clj
tr/edu/bilkent/cs/retop/main.clj
tr/edu/bilkent/cs/retop/util.clj

In retop.clj, I have below ns definition.

(ns tr.edu.bilkent.cs.retop
(:gen-class)
(:import
(com.sun.jna
Function
Pointer)
(com.sun.jna.ptr
IntByReference)
(tr.edu.bilkent.cs.patoh
HyperGraph
HyperGraphException
Parititoning
ParititoningParameters))
(:load
"retop/util"
"retop/km"
"retop/graph"
"retop/main"))

And in every .clj file in retop/ directory I have below in-ns in the
very first line.

(in-ns 'tr.edu.bilkent.cs.retop)

The problems with the ns decleration are:

1) Most of the :import's in retop.clj only belong to a single .clj file.
For instance,

(tr.edu.bilkent.cs.patoh
HyperGraph
HyperGraphException
Parititoning
ParititoningParameters)

imports are only used by graph.clj. Yep, I can add an (import ...)
line just after the (in-ns ...), but wouldn't it be better if I can
specify that in (in-ns ...) form?

2) See (:load ...) clause in (ns ...) form. There are lots of
unnecessary directory prefixes. I'd be prefer something ala Common
Lisp's defpackage:

(:load
"packages" ; packages.clj
("retop"
"util" ; retop/util.clj
"km" ; retop/km.clj
"graph" ; retop/graph.clj
("graph"
"foo" ; retop/graph/foo.clj
"bar) ; retop/graph/bar.clj
"main")) ; retop/main.clj

Also, being able to use wildcards would be awesome.

3) There are inconsistencies between macros and functions. For instance,
consider:

(ns foo.bar.baz (:use mov))
(in-ns 'foo.bar.baz)
(use 'mov)

I'd like to get rid of quotations in both cases.

I'm not sure if I'm using the right tools and doing the right approach
for such a project. But if you agree with the above overhauling
requirements, I'd like to see them appear in the same assembla ticket as
well.

Show
Assembla Importer added a comment - stu said: Suggestions from Volkan Yazici: Hi, I saw your "load/ns/require/use overhaul" ticket[1] and would like to ask for a few extra overhaulings. I have a project called retop, and here is its file hiearachy: tr/edu/bilkent/cs/retop.clj tr/edu/bilkent/cs/retop/km.clj tr/edu/bilkent/cs/retop/graph.clj tr/edu/bilkent/cs/retop/main.clj tr/edu/bilkent/cs/retop/util.clj In retop.clj, I have below ns definition. (ns tr.edu.bilkent.cs.retop (:gen-class) (:import (com.sun.jna Function Pointer) (com.sun.jna.ptr IntByReference) (tr.edu.bilkent.cs.patoh HyperGraph HyperGraphException Parititoning ParititoningParameters)) (:load "retop/util" "retop/km" "retop/graph" "retop/main")) And in every .clj file in retop/ directory I have below in-ns in the very first line. (in-ns 'tr.edu.bilkent.cs.retop) The problems with the ns decleration are: 1) Most of the :import's in retop.clj only belong to a single .clj file. For instance, (tr.edu.bilkent.cs.patoh HyperGraph HyperGraphException Parititoning ParititoningParameters) imports are only used by graph.clj. Yep, I can add an (import ...) line just after the (in-ns ...), but wouldn't it be better if I can specify that in (in-ns ...) form? 2) See (:load ...) clause in (ns ...) form. There are lots of unnecessary directory prefixes. I'd be prefer something ala Common Lisp's defpackage: (:load "packages" ; packages.clj ("retop" "util" ; retop/util.clj "km" ; retop/km.clj "graph" ; retop/graph.clj ("graph" "foo" ; retop/graph/foo.clj "bar) ; retop/graph/bar.clj "main")) ; retop/main.clj Also, being able to use wildcards would be awesome. 3) There are inconsistencies between macros and functions. For instance, consider: (ns foo.bar.baz (:use mov)) (in-ns 'foo.bar.baz) (use 'mov) I'd like to get rid of quotations in both cases. I'm not sure if I'm using the right tools and doing the right approach for such a project. But if you agree with the above overhauling requirements, I'd like to see them appear in the same assembla ticket as well.
Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/272

People

Vote (3)
Watch (7)

Dates

  • Created:
    Updated: