16 Matching Annotations
- Nov 2024
-
radanskoric.com radanskoric.com
-
The affinity to using meta-programming in Ruby is going to vary a lot between different development teams and it’s a very important factor in deciding whether to adopt gradual typing as the two work against each other.
-
- Dec 2023
-
stackoverflow.com stackoverflow.com
-
One language that is currently being developed, Rascal, takes a hybrid approach allowing dynamic typing within functions but enforcing static typing for the function signature.
first sighting: Rascal
-
- Oct 2023
- Nov 2022
-
stackoverflow.com stackoverflow.com
-
Honestly, at this point, I don't even know what tools I'm using, and which is responsible for what feature. Diving into the code of capybara and cucumber yields hundreds of lines of metaprogramming magic that somehow accretes into a testing framework. It's really making me loathe TDD despite my previous youthful enthusiasm.
opinion: too much metaprogramming magic
I'm not so sure it's "too much" though... Any framework or large software project is going to feel that way to a newcomer looking at the code, due to the number of layers of abstractions, etc. that eventually were added/needed by the maintainers to make it maintainable, decoupled, etc.
-
- Oct 2022
-
stackoverflow.com stackoverflow.com
-
opts = method(__method__).parameters.map(&:last).map { |p| [p, eval(p.to_s)] }.to_h SomeOtherObject.some_other_method(opts)
-
that's right, we don't want to do params = { ... } because then we're hardcoding the implementation and it becomes very coupled. The benefit of doing it like in my examples is that you can change the method signature and still automatically capture all keyword parameters.
-
- Feb 2022
-
github.com github.com
-
Replaces your Rails controllers, views and forms with meta programming. Considers routes.rb, ability.rb, current_user and does the right thing.
-
- Aug 2021
-
www.botsquad.com www.botsquad.com
-
medium.com medium.com
-
def destructure(method_name) meta_klass = class << self; self end method_proc = method(method_name) unless method_proc.parameters.all? { |t, _| t == :key } raise "Only works with keyword arguments" end arguments = method_proc.parameters.map(&:last) destructure_proc = -> object { values = if object.is_a?(Hash) object else arguments.map { |a| [a, object.public_send(a)] }.to_h end method_proc.call(values) } meta_klass.send(:define_method, method_name, destructure_proc) method_nameend
-
- Jun 2021
-
stackoverflow.com stackoverflow.com
-
class << Object def private_accessor(*names) names.each do |name| attr_accessor name private "#{name}=" end end end
-
-
github.com github.com
-
%w{ JsonDashArrow JsonDashDoubleArrow JsonHashArrow JsonHashDoubleArrow JsonbAtArrow JsonbArrowAt JsonbQuestion JsonbQuestionAnd JsonbQuestionOr CastJson }.each do |name| const_set name, Class.new(Binary) end
-
- Feb 2021
-
unix.stackexchange.com unix.stackexchange.com
-
for sig in $(kill -l) ; do trap "echo parent:$sig" $sig done
-
-
en.wikipedia.org en.wikipedia.org
-
The modern sense of "an X about X" has given rise to concepts like "meta-cognition" (cognition about cognition), "meta-emotion" (emotion about emotion), "meta-discussion" (discussion about discussion), "meta-joke" (joke about jokes), and "metaprogramming" (writing programs that manipulate programs).
-
-
doc.rust-lang.org doc.rust-lang.org
-
The most widely used form of macros in Rust is declarative macros. These are also sometimes referred to as “macros by example,” “macro_rules! macros,” or just plain “macros.” At their core, declarative macros allow you to write something similar to a Rust match expression.
Tags
Annotators
URL
-
- Apr 2020
-
stackoverflow.com stackoverflow.com
-
Ruby 2.1 added local_variable_set, but that cannot create new local variables either
-
-
stackoverflow.com stackoverflow.com
-
binding.local_variable_get and binding.local_variable_set
-