Clojure

Enhancement: give meaningful names to inline expanders

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.1
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

Currently inline expander fns are anonymous, so the errors they report have no context:

user=>  (pos? 3 4)
java.lang.IllegalArgumentException: Wrong number of args passed to: core$fn (NO_SOURCE_FILE:114)
</code></pre>

Could be fixed by supplying a name to expander:

<pre><code>:inline (fn pos? [x] ...)

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - oranenj said: [file:aOOXAsy_ir3RQ_eJe5afGb]
Hide
Assembla Importer added a comment -

oranenj said: Took about five minutes. It seems only clojure.core creates inline functions.

Behaviour with the patch applied:

user=> (pos? 3 4)
java.lang.IllegalArgumentException: Wrong number of args passed to: core$pos-QMARK- (NO_SOURCE_FILE:1)

Perhaps demangling for function names in error messages is next... I suspect it will require touching the java side, though.

Show
Assembla Importer added a comment - oranenj said: Took about five minutes. It seems only clojure.core creates inline functions. Behaviour with the patch applied: user=> (pos? 3 4) java.lang.IllegalArgumentException: Wrong number of args passed to: core$pos-QMARK- (NO_SOURCE_FILE:1) Perhaps demangling for function names in error messages is next... I suspect it will require touching the java side, though.
Hide
Assembla Importer added a comment -

chouser@n01se.net said: Thanks for the patch! Unfortunately it doesn't apply cleanly anymore – looks like some function definitions have moved around. Also doesn't appear to address functions produced by definline which have the same problem:

user=> (floats 1 2)
java.lang.IllegalArgumentException: Wrong number of args passed to: core$fn (NO_SOURCE_FILE:1)

Show
Assembla Importer added a comment - chouser@n01se.net said: Thanks for the patch! Unfortunately it doesn't apply cleanly anymore – looks like some function definitions have moved around. Also doesn't appear to address functions produced by definline which have the same problem: user=> (floats 1 2) java.lang.IllegalArgumentException: Wrong number of args passed to: core$fn (NO_SOURCE_FILE:1)
Hide
Assembla Importer added a comment -

mikehinchey said: [file:baIkEkGDOr3P4FeJe5aVNr]: patch to automatically give inline fn names

Show
Assembla Importer added a comment - mikehinchey said: [file:baIkEkGDOr3P4FeJe5aVNr]: patch to automatically give inline fn names
Hide
Assembla Importer added a comment -

mikehinchey said: The new patch I uploaded (clojure-136-inline.patch) has a different solution. defn will automatically add the same fn name to the :inline value if it doesn't have one.

Show
Assembla Importer added a comment - mikehinchey said: The new patch I uploaded (clojure-136-inline.patch) has a different solution. defn will automatically add the same fn name to the :inline value if it doesn't have one.
Hide
Assembla Importer added a comment -

chouser@n01se.net said: Mike, I like your approach – would you bring the closing bracket up to the previous line? It's hard to know what good style is when you don't have 'and' or 'when', but I think we can do that much. Mark it as 'test' again when you've got that attached.

This still needs Rich's approval, so I'm bumping it back to Unapproved.

Show
Assembla Importer added a comment - chouser@n01se.net said: Mike, I like your approach – would you bring the closing bracket up to the previous line? It's hard to know what good style is when you don't have 'and' or 'when', but I think we can do that much. Mark it as 'test' again when you've got that attached. This still needs Rich's approval, so I'm bumping it back to Unapproved.
Hide
Assembla Importer added a comment -

mikehinchey said: [file:aMYigUHWer3RyjeJe5afGb]: revised patch to automatically give inline fn names

Show
Assembla Importer added a comment - mikehinchey said: [file:aMYigUHWer3RyjeJe5afGb]: revised patch to automatically give inline fn names
Hide
Assembla Importer added a comment -

mikehinchey said: Okay. clojure-136-inline2.patch fixes the bracket and cleans it up more, plus comments.

Show
Assembla Importer added a comment - mikehinchey said: Okay. clojure-136-inline2.patch fixes the bracket and cleans it up more, plus comments.
Hide
Assembla Importer added a comment -

chouser@n01se.net said: Mike, looks good to me.

Show
Assembla Importer added a comment - chouser@n01se.net said: Mike, looks good to me.
Hide
Assembla Importer added a comment -

technomancy said: Looks like this still cleanly applies to master and does what it says on the box.

Show
Assembla Importer added a comment - technomancy said: Looks like this still cleanly applies to master and does what it says on the box.
Hide
Assembla Importer added a comment -

mikehinchey said: (In [[r:1b4852fdbd5ca8df86e783e417f01c8db226d428]]) give meaningful names to inline expanders, fix #136

Signed-off-by: Rich Hickey <richhickey@gmail.com>

Branch: master

Show
Assembla Importer added a comment - mikehinchey said: (In [[r:1b4852fdbd5ca8df86e783e417f01c8db226d428]]) give meaningful names to inline expanders, fix #136 Signed-off-by: Rich Hickey <richhickey@gmail.com> Branch: master

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: