Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#131 closed defect (released)

Ruby bindings don't support @stem.apply()

Reported by: Richard Boulton Owned by: Olly Betts
Priority: normal Milestone: 1.0.0
Component: Xapian-bindings Version: SVN trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: #118 Operating System: All

Description (last modified by Richard Boulton)

Ruby is meant to support the Stem.operator() call by renaming it to Stem.apply(). However, this renaming doesn't seem to work: Stem.apply() isn't found.

Looking at the generated code, Ruby provides access to operator() with a call() method: ie, @stem.call() works with Ruby, @stem.apply() doesn't.

I would guess this is a bug in Swig, since it seems to be ignoring the "%rename(apply) operator();" line in xapian.i

Change History (8)

comment:1 by Richard Boulton, 18 years ago

Blocking: 118 added

Marking this as blocking release 1.0.0 since we don't want people to start relying on the @stem.call() method, and we want to deprecate @stem.stem_word() so we can remove it in sync with the C++ interface for release 1.1.0.

comment:2 by Richard Boulton, 18 years ago

rep_platform: PCAll

comment:3 by Olly Betts, 18 years ago

I think this renaming of operator() to call is SWIG trying to provide a functor like interface in Ruby, so this may be "not a bug" (or "not the bug reported").

My understanding of Ruby isn't great though, and I'm struggling to find something which tells me how this is meant to work...

comment:4 by Richard Boulton, 18 years ago

For what it's worth, the rename to call is happening because of line 29 of Lib/ruby/rubyopers.swg in the swig source tree:

%rename(call) *::operator();

In combination with line X of Source/Modules/ruby.cxx:

Setattr(special_methods, "call", "call");

Hmm - a quick bit of reading google results leads me to believe that "call" is the standard name for a message saying "call this object" - but I've only found this hinted at in a FAQ for teaching Python programmers Ruby. We really need a proper Ruby programmer to tell us what's right, I think.

comment:5 by Olly Betts, 18 years ago

I've mailed Paul Legato, the Ruby guru who originally contributed the Ruby bindings.

comment:6 by Olly Betts, 18 years ago

Resolution: fixed
Status: newclosed

Paul says:

"call() would definitely be more idiomatic than apply() in

Ruby"

So I've added a note to the Ruby bindings documentation and I'm closing this bug.

comment:7 by Olly Betts, 17 years ago

Operating System: All
Resolution: fixedreleased

Fixed in 1.0.0 release.

comment:9 by Richard Boulton, 17 years ago

Description: modified (diff)
Milestone: 1.0.0
Note: See TracTickets for help on using tickets.