Clojure

Remove the need to use ":import" of a record

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Right now if I need to use a record defined in another name space, I need to do this:

(ns myproj.test.xyz
(:use [myproj.xyz])
(:import [myproj.xyz MyRecord])

Hope we can remove the need of ":import" clause.

Activity

Hide
Stuart Halloway added a comment -

Hi Warren,

Importing a Java class and using a record are two logically distinct ideas, hence two separate steps in your code. Note that using a namespace makes the defrecord constructor fns (e.g. >MyRecord and map>MyRecord) available without a second step.

Please discuss ideas on the mailing list before using JIRA to make suggestions.

Cheers

Show
Stuart Halloway added a comment - Hi Warren, Importing a Java class and using a record are two logically distinct ideas, hence two separate steps in your code. Note that using a namespace makes the defrecord constructor fns (e.g. >MyRecord and map>MyRecord) available without a second step. Please discuss ideas on the mailing list before using JIRA to make suggestions. Cheers
Hide
Warren Lynn added a comment -

Thanks for giving it a thought.

I think it is conceptually simple/consistent to say "if you use a namespace, then all the public symbols in that namespace is available without namespace qualification". It is unnecessary to remind people "Hey, record is an actually a Java class so the rules do not apply". I think it is the right choice for Clojure to integrate closely with the host language, but it is not the objective to expose the host details when not needed. If you say "this is a compromise due to some implementation consideration", then I can understand. But I disagree with the rationale you mentioned.

Show
Warren Lynn added a comment - Thanks for giving it a thought. I think it is conceptually simple/consistent to say "if you use a namespace, then all the public symbols in that namespace is available without namespace qualification". It is unnecessary to remind people "Hey, record is an actually a Java class so the rules do not apply". I think it is the right choice for Clojure to integrate closely with the host language, but it is not the objective to expose the host details when not needed. If you say "this is a compromise due to some implementation consideration", then I can understand. But I disagree with the rationale you mentioned.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: