Comments (7)
Well, good that this has been brought up! In particular, this is clashing with a match
method that is supposed to be available whenever you want to define an RSpec matcher by yourself, for instance:
require 'rspec/expectations'
RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
end
from rltk.
Well @codella actually I have found a workaround.
in your node class you could do
require 'rltk/ast'
Object.send :undef_method, :match
class BaseNode < RLTK::ASTNode
..
end
But, yes... not very elegant. It would be better if we just include Filigree::Destructurable
and avoid defining match
on the Object
class
from rltk.
This is certainly something I can work on. I might need your help with testing though, as I currently don't have any environment that causes this problem.
I'd appreciate it if you could also leave me a short description of how/why you are using RLTK. This helps me understand how people are using RLTK and if it is meeting people's needs.
from rltk.
So, my match
is a function and not a method of some particular object. It looks like Ruby might implement functions by making them methods of Object, but that doesn't always seem to be the case. Can you get your code to work by using self.match
instead of match
? If that doesn't work, the only solution I see is to re-name the Filigree-provided function to something like pmatch
(for 'pattern-match').
from rltk.
Hi
At this moment in time I can't disclose what we are working on, I am sorry. Anyway we have all the intentions to opensource the project as soon as possible.
The issue we see here is that after require 'filigree/match'
any constants, method or globals within the loaded source file will be available in the calling program’s global namespace.
When you do a
def match
puts "foo"
end
you are actually defining a method in the ruby main
object
» irb
def match; puts "foo"; end
method(:match).owner
=> Object
self
=> main
Instead of renaming it with pmatch
(so to introduce some sort of naming spacing "p") why don't you go for a real namespace and use a module
module Filigree
def match
puts "foo"
end
end
The function will be still available as a global ::Filigree.match
from rltk.
I can confirm that this would work
require 'rspec/expectations'
RSpec::Matchers.define :be_a_multiple_of do |expected|
self.match do |actual|
actual % expected == 0
end
end
The point is that rspec is loaded before Filigree and hence the latest will define a match
method that will override the one in rspec even if they define it in a module:
https://github.com/rspec/rspec-expectations/blob/7628434b8e10620669bf34f9b341acbd7e5946ee/lib/rspec/matchers/dsl.rb#L57
(is still a supposition, I am trying to prove it but it's not easy to find out what is going in rspec sourcecode)
In my humble opinion your match function as it is now is hitting a bit the principle of least astonishment .
Sorry for my rant :-)
from rltk.
This issue was fixed by moving the match function provided by Filigree into the Filigree namespace. Please file any followup issues to the Filigree Github page.
Relevant patch: chriswailes/filigree@ead2f44
from rltk.
Related Issues (20)
- Move to LLVM 3.6 HOT 1
- Remove support for LLVM::JIT in anticipation of LLVM 3.6 release
- Rejecting a clause in a production HOT 2
- A more complete example for error production HOT 2
- RLTK::LexingError carries a wrong line_offset. HOT 6
- :pointer argument is not a valid pointer
- Calling #type on RLTK::CG::Value throws an error
- JITCompiler segfaults on OSX
- Split the LLVM bindings into their own project: RCGTK
- RLTK::Parser.finalize use: fails to load cache on Windows
- left/right associativity maintains separate precedence stacks
- LLVM HOT 2
- undefined method `subclass_of?' HOT 1
- Requires Ruby >= 2.4.0 due to Filigree HOT 1
- rltk (3.0.1) does not work with filigree (0.4.1) due to check_type signature
- Cannot Generate YARD documentation
- Make a release? HOT 2
- "String not in language" error HOT 2
- undefined method 'subclass_of?', no such file or directory HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rltk.