<havenwood>
rapha: There was one proposed initially, and it was going to destructure differently than it ended up.
<havenwood>
rapha: But _0 wasn't the first argument. :O
<rapha>
let's say a=[[:a, :b, :c], [:d, :e, :f], [:g, :h, :i]] ... now a.map{_1} returns a, whereas _2 returns [:b, :e, :h] as expected
<havenwood>
rapha: Anyways, it ended up a bit simpler, following Elixir's pattern pretty much.
BSaboia has joined #ruby
<havenwood>
rapha: You can do other things with traditional block arguments.
<havenwood>
&>> a.map { |_first, *rest| rest }
<rubydoc>
stderr: -e:4:in `<main>': undefined local variable or method `a' for main:Object (NameError)... check link for more (https://carc.in/#/r/9wji)
<rubydoc>
# => [42] stderr: -e:4: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call... check link for more (https://carc.in/#/r/9wjk)
<rubydoc>
stderr: /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- mll/core_ext (LoadError)... check link for more (https://carc.in/#/r/9wjl)
<nakilon>
it's not stdlib ) it's my old gem I stopped developing
<rapha>
shame, that woulda been kinda nice ... but conflicting with class variables
<nakilon>
would be cool if it was \1, \2
<rapha>
havenwood: sorry, but even according to that article, by all means, [[:a, :b, :c], [:d, :e, :f], [:g, :h, :i]].map{_1} *should* result in [:a, :d, :g] and not in [[:a, :b, :c], [:d, :e, :f], [:g, :h, :i]]!
<rapha>
\n was probably deemed to difficult to implement, no?
<nakilon>
better be difficult to implement than difficult to use; _1, _2 are conflicting with local variables
<rapha>
oh, never saw someone use _1 ... interesting. what do ppl use that for?
<havenwood>
rapha: I think it would have been viable but just wasn't chosen.
<havenwood>
nakilon: warning: `_1' is reserved for numbered parameter; consider another name
<nakilon>
_1 is reserved for my needs
<havenwood>
rapha: It would be a convention to say there's a variable `1` that's unused, which is why it's not a problem.
<nakilon>
those have to consider who make things AFTER others already using this syntax
<havenwood>
nakilon: To represent an unused local variable that can't be named `1`? :P
<havenwood>
nakilon: Yes, it could be used but violates convention for _ variable use, so seemed fine to me.
<nakilon>
it's not convinient
<havenwood>
what's inconvenient about it?
<havenwood>
rapha: The destructuring worked differently in earlier versions.
<nakilon>
people already use this syntax
<nakilon>
the new feature isn't compatible
* rapha
is still hung up on [[3,4],[8,9]].map{_1} not working and wondering if that might be a bug
<leftylink>
ah yeah, I had to deal with that a while ago
<havenwood>
nakilon: So if you have a variable `name` and won't be using it, you write `_name`. But `1` or `2` another other Integers aren't allowed as a variable name.
<leftylink>
so it's just like this
<havenwood>
rapha: No, it used to work differently and this was selected. There's a long ruby issue thread.
<rapha>
havenwood: what do you mean by "selected"?
<nakilon>
but what if variable names _1, _2, _3 perfectly fit my code?
<havenwood>
rapha: There were multiple implementations floated.
<leftylink>
&>> a = [[1, 2], [3, 4]]; [a.map { _1 }; a.map { |x| x }, a.map { _2; _1 }, a.map { |x, _|, x }]
<nakilon>
in new Ruby they'll be shaded by any nested block now
<rubydoc>
stderr: -e:4: syntax error, unexpected ';', expecting ']'... check link for more (https://carc.in/#/r/9wjm)
<leftylink>
nooooo
<leftylink>
&>> a = [[1, 2], [3, 4]]; [a.map { _1 }, a.map { |x| x }, a.map { _2; _1 }, a.map { |x, _|, x }]
<rubydoc>
stderr: -e:4: syntax error, unexpected ','... check link for more (https://carc.in/#/r/9wjn)
<nakilon>
*shadowed
<leftylink>
nooooooooooooooooooooooooooo
<rapha>
havenwood: so are you saying that the result [3,8] is not accessible in any way with the underscore-plus-integer syntax?
<leftylink>
&>> a = [[1, 2], [3, 4]]; [a.map { _1 }, a.map { |x| x }, a.map { _2; _1 }, a.map { |x, _| x }]
<leftylink>
there we go. that should make it clear
<leftylink>
the first two are exactly analogous to one another, as are the last two
<rapha>
a.map{_2;_1} ... what ... the ... marsrover?!
<nakilon>
actually my argument isn't even "what if?" but confirmed by the Ruby itself
<havenwood>
nakilon: Since you couldn't choose it as a variable name it doesn't bother me in the least that you can't choose it for a shadowed variable name. I makes sense to warn even in the least in the absence of this feature.
<rapha>
btw i think havenwood has a good point there nakilon
<havenwood>
nakilon: You may want a `1` and `_1` variable but... Integers!
<nakilon>
what do you mean I could not choose it as a variable name?
<rapha>
okay, a.map{|x,_|x} i can still accept
<havenwood>
&>> 1 = 42
<rubydoc>
stderr: -e:4: syntax error, unexpected '=', expecting `end'... check link for more (https://carc.in/#/r/9wjp)
<havenwood>
nakilon: local variables cannot start with integers.
<havenwood>
nakilon: prepending an underscore suggests the variable will not be used. you should be able to remove the prepended _ without a syntax error.
<nakilon>
I don't mean the variable names starting with digits, I never said that
<havenwood>
nakilon: You've named your _variable badly if you cannot remove the _.
<havenwood>
It didn't warn (since it wasn't considered anyone would do this) but a warning would have always been appropriate.
<havenwood>
It still is just a warning.
<leftylink>
if you want to look back in the logs at where I had to deal with this, the first line of the log is
<leftylink>
2020-10-23 10:37:37 < leftylink> just want to know how ruby could know what I mean when I write _1
<havenwood>
You can do it if you like.
<havenwood>
(I won't.)
<nakilon>
"prepending an underscore suggests the variable will not be used" -- why do think so? it's like your opinion; why you think it meant "not gonna be used" for me? and why do you think in new verison of Ruby they suddently should stop meaning they aren't meant to be used?
<havenwood>
nakilon: It's a Ruby convention. ¯\_(ツ)_/¯
<nakilon>
if we implement this feature that definitely means "oh we like the variable name starting with dash" and how then you can say that "dash meant it's not gonna be used"? that's oxymoron
<nakilon>
now it is not
<nakilon>
it's a convention of those who did bad by implementing this
<nakilon>
they didn't care that will break programs of those people who were not called to discuss it
<havenwood>
nakilon: The reason to allow an underscore is for the convention. If you're using local variables with underscores for other reasons, you're doing it wrong.
<rapha>
havenwood: i have a wierd thing here now where i try to .map an sqlite3 result set and after .map{|x,_|x}, a second call to .map (with {_2}) only returns an empty array. as if the first map had been a bang method.
<havenwood>
rapha: Show a short reproduction example?
<leftylink>
&>> [1].map { |;_1| _1 }
<rubydoc>
# => [nil] stderr: -e:4: warning: `_1' is reserved for numbered parameter; consider another name (https://carc.in/#/r/9wjv)
<leftylink>
that is completely useless, but I guess I can do that
<leftylink>
if I really want to
<rapha>
havenwood: just figured it out. the result set only behaves similar to an array, but isn't one. doing #to_a first makes it work just fine.
<havenwood>
Here's a fun one: How do you explicitly not pass a block with &?
<leftylink>
I have never done that, but maybe I will someday
<havenwood>
nakilon: What should `wombat` be fore the result of `Bongo.new.foo(true) { }` to be `{:arg=>true, :block=>false}`: class Bongo < Foo; def foo *args; super *args, &wombat; end; end
<havenwood>
nakilon: Oh, sorry, I didn't give the code, haha.
<havenwood>
nakilon: class Foo; def foo arg = false; {arg: arg, block: block_given?}; end; end
<leftylink>
what was that quote where the kid goes "wdog" ?
<leftylink>
like "what's this animal's name? it starts with w"
<havenwood>
leftylink: woodpecker
<havenwood>
leftylink: wooly mammoth
<havenwood>
leftylink: so many
<havenwood>
leftylink: wolverine
<havenwood>
leftylink: what's a wdog?
<leftylink>
once I find the quote I'll be able to tell you
imode has quit [Ping timeout: 256 seconds]
<leftylink>
can't find it. giving up
<leftylink>
a kid and a dad at a zoo
<havenwood>
nakilon: Anyway, I clearly need coffee *before* suggesting challenges. >.>
<havenwood>
What I was meaning as the answer was: &nil
<nakilon>
leftylink solved it though
<havenwood>
nakilon: Oh, I didn't even see!
<havenwood>
leftylink: You win!
* havenwood
crawls away in search of coffee
<havenwood>
Also leftylink's example was coherent. :)
<leftylink>
there is a big difference between being told that something is possible and then only needing to figure out what makes it possible vs not knowing whether it is possible at all and never thinking whether to test the limits and try it
<leftylink>
like how the announcements before the plane takes off always say "please make sure aisle armrests are lowered"
<leftylink>
it makes you think
<leftylink>
"uh, they can be raised?"
<leftylink>
and now you know it's possible to raise them and now all you need to do is figure out how
<leftylink>
whereas if they hadn't told you, you wouldn't think to try, because at first try it appears they are fixed in place
<nakilon>
"hacking" is basically about finding unexpected things
<leftylink>
I see this doesn't even follow the rules; nil doesn't even have to_proc
<leftylink>
&>> nil.to_proc
<rubydoc>
stderr: -e:4:in `<main>': undefined method `to_proc' for nil:NilClass (NoMethodError)... check link for more (https://carc.in/#/r/9wjx)
<nakilon>
that probably means that it's not a rule but an observation, and the nil-check is somewhere in C
<nakilon>
recently I tried to make the code faster by reimplementing the Array#zip, making it 10 times smaller because I know the sizes of arrays, etc. but it didn't made things faster at all
<nakilon>
because as I understood the bottleneck is in args being passed to a block -- it created an array for it
<nakilon>
the only way to make it faster would be to rewrite the block to C
<nakilon>
I mean when I do [1,2].zip [3,4] it internally creates [1,3] and [2,4] just to pass it to the block
<nakilon>
I imagine some kind of implementation where it does not happen if the block is splatting them immediately
dviola has joined #ruby
TCZ has joined #ruby
<nakilon>
I guess I found that code https://dpaste.org/W3so/slim -- here you have to do the rb_ary_new_from_args to then pass it to rb_yield
akem has quit [Ping timeout: 260 seconds]
<nakilon>
instead of passing the RARRAY_AREF to it directly
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
wimpog has joined #ruby
dviola has joined #ruby
TCZ has quit [Quit: Leaving]
<nakilon>
faster by 20%
akem has joined #ruby
BSaboia has joined #ruby
Technodrome has joined #ruby
olspookishmagus has quit [Ping timeout: 272 seconds]
cd has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellcs has joined #ruby
zacts has quit [Quit: leaving]
alexherbo2 has joined #ruby
rmnull has joined #ruby
meinside has quit [Quit: Connection closed for inactivity]
silverdust has quit [Ping timeout: 260 seconds]
TCZ has joined #ruby
CalimeroTeknik has quit [Ping timeout: 260 seconds]
CalimeroTeknik has joined #ruby
alexherbo2 has quit [Ping timeout: 272 seconds]
wimpog has quit [Quit: wimpog]
_whitelogger has joined #ruby
alexherbo2 has joined #ruby
ruurd has joined #ruby
mohsen_in has joined #ruby
wimpog has joined #ruby
silverdust has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
zacts has joined #ruby
ChmEarl has joined #ruby
wimpog has quit [Quit: wimpog]
ua has quit [Ping timeout: 256 seconds]
zacts has quit [Quit: leaving]
carbone5 has joined #ruby
chouhoulis has joined #ruby
TCZ has quit [Quit: Leaving]
carbone5 has quit [Quit: carbone5]
wimpog has joined #ruby
carbone5 has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wimpog has quit [Quit: wimpog]
Technodrome has joined #ruby
Technodrome has quit [Remote host closed the connection]
wimpog has joined #ruby
mohsen_in has quit [Remote host closed the connection]
mohsen_in has joined #ruby
<extrowerk>
Hi,
<extrowerk>
i am with the HaikuPorts team, and i am maintaining the ruby port since some years.
BenDover has joined #ruby
<extrowerk>
Ruby requires some patching on Haiku, but it wasn't a problem so far, but since 2.7 it asks for baseruby during the compilation.
<extrowerk>
According the devs ruby doesn't need ruby to build itself , but it does for us. 9 times from 10. in the last one cae it builds just miniruby and then builds everything happily.
<extrowerk>
it is absolutely unpredictable
<extrowerk>
We definetely don't want a circular dependency where ruby requires ruby on our build farms
<extrowerk>
But i can't seem to find out why it actually needs baseruby (sometiems)
<extrowerk>
one said we probably changed some .y files, that's why baseruby required, but we never patched any .y file
<extrowerk>
So i am out of ideas, competely
<extrowerk>
is there anybody up to the task to help me to find out whats going on?
wimpog has quit [Quit: wimpog]
wimpog has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
alexherbo24 has joined #ruby
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo24 is now known as alexherbo2
silverdust has quit [Ping timeout: 240 seconds]
silverdust has joined #ruby
<havenwood>
extrowerk: Hi! Are you patching configure.in?
<VicMackey>
[debian, sid] Hello there! I am new to Ruby! I am trying to install Rails, but nokogiri won't compile. I've tried installing the dev libraries required by nokogiri, but still no luck :/ I am using rbenv and Ruby 2.7.2: https://dpaste.org/GPfz
<jhass>
huh, uninitialized constant MiniPortile, that's a new one
<VicMackey>
Maybe I was too eager by going with the latest Ruby version?
<VicMackey>
Is this a bug, should I report it or something?
<VicMackey>
I mean... I had Ruby 7.2 installed through the package manager, but I've read that it is better to use rbenv or rvm... So I installed it, plus Ruby 2.7.2, and then I can't install Rails because of htis error
<VicMackey>
Yep, I saw that... I've tried other answers, to see if I was lacking something... Checked all the dependencies, installed also some *-dev ones for Ruby, but no luck...
<VicMackey>
Maybe it has something to do with the virtualized Ruby environment
<VicMackey>
I guess
<jhass>
does a simple gem install mini_portile change anything?
<jhass>
or gem install mini_portile2 fwiw
<VicMackey>
No... I installed both
<VicMackey>
But it still gives me the same error
<VicMackey>
Anyway... is this the regular way of installing Ruby? Because I'm thinking on a production environment... Do people install rbenv there too, and deploy apps there? Or even if you use a Docker image or something
<jhass>
I can't say there's a clear way. All is not unseen, rbenv/rvm/chruby based setups, docker based setups, just going with the OS'es package manager, sometimes with special repos like https://www.brightbox.com/docs/ruby/ubuntu/
silverdust has joined #ruby
<jhass>
you're definitely not doing anything fundamentally wrong here picking rbenv, would've pointed that out otherwise :)
<jhass>
but yeah, carefully nuking the Rbenv install and trying RVM or a chruby + ruby-install based setup might be worth a shot
<jhass>
make sure to drop stuff from temporary directories/caches too then, and ~/.gem
<VicMackey>
Alright, thanks! Maybe I should note that I dist-upgraded the system because an old openssl library incompatible with the newest ruby... Maybe I've screwed everything up
<VicMackey>
I'll try that tomorrow then. Thanks jhass!
<jhass>
gladly :)
<jhass>
and good luck
<VicMackey>
Thank you!
oneeggeach has joined #ruby
ellcs has joined #ruby
oneeggeach has quit [Remote host closed the connection]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]
VicMackey has quit [Quit: Konversation terminated!]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]
oneeggeach has joined #ruby
oneeggeach has quit [Remote host closed the connection]