|
Rufo posted:1. perl flattens arrays. ((1,2),(3,4)) means (1,2,3,4). this includes @_, the array of parameters received by a subroutine. so good luck passing two arrays, or anything more complicated, without the help of references lol
|
# ? May 27, 2012 22:17 |
|
|
# ? May 9, 2024 09:51 |
|
Rufo posted:1. perl flattens arrays. ((1,2),(3,4)) means (1,2,3,4). this includes @_, the array of parameters received by a subroutine. so good luck passing two arrays, or anything more complicated, without the help of references Curious to know why this is. (I guess its because everything just gets pushed onto the stack? Which would explain why/how shift works.)
|
# ? May 27, 2012 22:22 |
|
BonzoESC posted:it was a rhetorical question, yeah my reply was mainly for the benefit of people who dont know perl BonzoESC posted:$ref->{'whatever'}{'row'}{'column'} is objectively worse than ref['whatever']['row']['column'] took me a while to work out why, but now i agree wholeheartedly BonzoESC posted:everything in ruby is pass-by-reference-to-object yeah this is really neat and consistent BonzoESC posted:especially if the former is a world where "$arrayref->[123] meaning ${$arrayref}[123]" is true not sure how this makes it worse than it otherwise is but w/e
|
# ? May 27, 2012 22:59 |
|
I don't see anything objectively wrong with being explicit about references, besides it being kind of annoying to learn. Javascript, for example, is clearly using references for arrays behind the scenes, but it pretends it's treating them the same way it treats scalars. But then when you try to copy an array with arrOne = arrTwo Javascript gets all sheepish and says "well you see the thing about that is..."
|
# ? May 27, 2012 23:09 |
|
i start next week at my new job doing java and i keep thinking to myself hmm i should brush up on my java or something but i don't do it because honestly it's loving java how hard can it be
|
# ? May 27, 2012 23:57 |
|
HORATIO HORNBLOWER posted:i start next week at my new job doing java and i keep thinking to myself hmm i should brush up on my java or something but i don't do it because honestly it's loving java how hard can it be its the deployment that's gonna kick your rear end
|
# ? May 27, 2012 23:58 |
|
probably
|
# ? May 27, 2012 23:58 |
|
i don't think that'll be my responsibility but ~~you never know~~
|
# ? May 28, 2012 00:02 |
|
HORATIO HORNBLOWER posted:i start next week at my new job doing java and i keep thinking to myself hmm i should brush up on my java or something but i don't do it because honestly it's loving java how hard can it be java is super easy. java ftw
|
# ? May 28, 2012 00:03 |
|
ahhh spiders posted:java is super easy. java ftw
|
# ? May 28, 2012 00:04 |
|
java is cool because the complexity is in random things not working & gaps in cross-platform functionality, and also over-designed APIs
|
# ? May 28, 2012 00:07 |
|
Sang- posted:Curious to know why this is.
|
# ? May 28, 2012 00:08 |
|
Rufo posted:took me a while to work out why, but now i agree wholeheartedly idgi
|
# ? May 28, 2012 00:15 |
|
Stringent posted:idgi its conceptually pretty neat to make everything an object and pass everything by reference and make [_] a method call rather than treating arrays as some special entity and managing ref/deref yourself. the way perl does things is a good solution, albeit a solution to a problem of its own creation. i guess the ruby way means you need some kind of clone operation in the language though so maybe its not as neat and clean as it first appears. i dont know ruby
|
# ? May 28, 2012 00:33 |
|
Rufo posted:its conceptually pretty neat to make everything an object and pass everything by reference and make [_] a method call rather than treating arrays as some special entity and managing ref/deref yourself. the way perl does things is a good solution, albeit a solution to a problem of its own creation. oh ok, i thought you meant there was something objectively better about the syntax itself.
|
# ? May 28, 2012 00:39 |
|
Rufo posted:i guess the ruby way means you need some kind of clone operation in the language though so maybe its not as neat and clean as it first appears. i dont know ruby "clone" is a method implemented on Object and if you need a given class to always deep copy you can override "initialize_copy" to clone all its members
|
# ? May 28, 2012 00:42 |
|
Stringent posted:oh ok, i thought you meant there was something objectively better about the syntax itself. there's less of it
|
# ? May 28, 2012 00:42 |
|
Sang- posted:Curious to know why this is. Because the same list syntax e.g. (1, 2, 3, 4) or (1 => 2, 3 => 4) is used to declare both arrays and hashes. Both of those expressions are the same list. => is just a synonym for ,. So Perl has no way of knowing whether a given list expression is supposed to declare an array or a hash, so it assumes neither and flattens the list out. There's probably a page and a half in Programming Perl where Larry Wall explains why this is actually completely intuitive and obvious and logical and useful.
|
# ? May 28, 2012 00:53 |
|
qntm posted:Because the same list syntax e.g. (1, 2, 3, 4) or (1 => 2, 3 => 4) is used to declare both arrays and hashes. Both of those expressions are the same list. => is just a synonym for ,. So Perl has no way of knowing whether a given list expression is supposed to declare an array or a hash, so it assumes neither and flattens the list out. There's probably a page and a half in Programming Perl where Larry Wall explains why this is actually completely intuitive and obvious and logical and useful.
|
# ? May 28, 2012 00:56 |
|
hardest part about java is getting eclipse and all of its plugins to work on the first install, and then run smoothly on anything if you are doing tomcat at the same time.
|
# ? May 28, 2012 01:00 |
|
qntm posted:Perl has no way of knowing whether a given list expression is supposed to declare an array or a hash, so it assumes neither and flattens the list out. eh lol no its essentially because this Gazpacho posted:it's because perl up to version 4 literally had no direct way to express a list of lists, so there was never any choice of what to do with nested lists other than flattening them
|
# ? May 28, 2012 01:07 |
|
BonzoESC posted:"clone" is a method implemented on Object and if you need a given class to always deep copy you can override "initialize_copy" to clone all its members sounds good so far. whats the catch w/ ruby
|
# ? May 28, 2012 01:09 |
|
Rufo posted:sounds good so far. whats the catch w/ ruby the ruby community
|
# ? May 28, 2012 01:10 |
|
chunky bacon lol
|
# ? May 28, 2012 01:11 |
|
fidel sarcastro posted:the ruby community "the ruby community" hasnt existed in the form you think it does since about 2008
|
# ? May 28, 2012 01:21 |
|
MSPain posted:hardest part about java is getting eclipse and all of its plugins to work on the first install, and then run smoothly on anything if you are doing tomcat at the same time. imo the hardest part about java is knowing you could do the same poo poo with like 1/5th the typing in like python or ruby (or about a 1:30 ratio in clojure).
|
# ? May 28, 2012 01:45 |
|
trex eaterofcadrs posted:imo the hardest part about java is knowing you could do the same poo poo with like 1/5th the typing in like python or ruby (or about a 1:30 ratio in clojure). and no type checking
|
# ? May 28, 2012 01:58 |
|
Rufo posted:2. perl passes everything by value (when youre passing a reference youre still just passing a scalar by value) um, perl is call by reference. python and ruby are call by object (i.e call by value where the value is a reference). in perl you can write a subroutine called swap, and do swap($a,$b)
|
# ? May 28, 2012 01:59 |
|
Rufo posted:i only know a small amount of python but im reliably informed that whoever told you this has no loving idea what they are talking about. call by reference languages are not the same as call by values, where the values are references
|
# ? May 28, 2012 02:02 |
|
quote:the following types, and their subclasses, pass by reference: aka someone is full of poo poo. the first one is mutable and the second one is immutable. seriously, it turns out that passing a reference to an immutable value is almost indistinguishable from passing that value. if you can do pass by reference, you can call a function swap(a,b) and that function can re-assign a,b within its scope and it affects the callee. meanwhile, in a call by value language, you can't. perl and python are call by object value. so you pass a pointer/reference to the object to the function, and you can mutate what they point to, but you can't rebind the arguments. what are they teaching you rufo tef fucked around with this message at 02:14 on May 28, 2012 |
# ? May 28, 2012 02:07 |
|
HAY IS JAVA CALL BY VALUE OR CALL BY REFERENCE
|
# ? May 28, 2012 02:15 |
|
i call huim hopkin green frog
|
# ? May 28, 2012 02:16 |
so the camel book is basically the k&r for perl right?
|
|
# ? May 28, 2012 02:18 |
|
tef posted:um, perl is call by reference. python and ruby are call by object (i.e call by value where the value is a reference). you used to be able to with evil.rb: http://www.koders.com/ruby/fid071535C0BD128E011EDCB3D9E4EFF0EE14607435.aspx#L464
|
# ? May 28, 2012 02:21 |
|
Sulk posted:so the camel book is basically the k&r for perl right? yeah but much more in-depth
|
# ? May 28, 2012 02:22 |
|
Rufo posted:the short answer is "because you have to, because youre forced to handle references yourself, because of the way perl works" Here's some fun: code:
code:
|
# ? May 28, 2012 02:22 |
|
homercles posted:Here's some fun: wtf
|
# ? May 28, 2012 02:25 |
|
your first mistake was reading my post
|
# ? May 28, 2012 02:34 |
|
Q: How many perl programmers does it take to change a light bulb? A: HASH(0x814f708).
|
# ? May 28, 2012 02:36 |
|
|
# ? May 9, 2024 09:51 |
|
scalar %a is number of buckets in use/total available buckets, %a = (1..10) creates a hash mapping 1 to 2, 3 to 4, etc
|
# ? May 28, 2012 02:48 |