« first day (1412 days earlier)      last day (3539 days later) » 

11:01 PM
12 pokemon episodes in -_- #no-shame
 
11:12 PM
@Ronnie Jesus fuck. What is wrong with these people. — R. Martinho Fernandes 2 mins ago
this thread is hilarious
 
OMFG TIL count() has a recursive parameter :O
 
it does make you wish any question with "syntax error" in the title got automatically closed
 
They should
 
@BartekBanachewicz It is.
 
@PeeHaa what's a recursive parameter? #interested
 
11:16 PM
int count ( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] )
COUNT_RECURSIVE
mind blown
 
wait
you mean that you can choose the implementation basing on that parameter?
 
@BartekBanachewicz Yea.
 
what purpose does it serve, out of curiosity?
 
@PeeHaa Noob.
 
@BartekBanachewicz The recursive flag?
 
11:20 PM
@BartekBanachewicz count([[[[[[[]]]]]]]) // 6 instead of 1
 
@PeeHaa yep.
 
@webarto I don't think I had ever the need to actually do it :P
 
Sorry for the multi-ping. I blame the booze
 
@BartekBanachewicz I'm still trying to find a use case for it, but somebody had it apparently :P
 
@PeeHaa Yea, the same thing was said about array_column
 
11:21 PM
@DanLugg what's count([ [], [[]], [[[]]] ]) then?
 
6
Total number of elements contained within the array argument and all arrays therein.
 
Hence recursive.
 
should be another function, IMHO, but I get the idea.
 
Without the recursive flag, it'd be 3
 
11:23 PM
rand works fine, you just didn't bother to read the manual on how to use it properly — Dagon 48 secs ago
Blaming the innocent rand(). asshole
 
in case, for example, you want to know how many nodes you have in a tree structure
 
@PeeHaa Maybe in some tree structures
@derp I thought the same, but I would still rather count each and add up.
 
@derp Arrays for tree structures are an "oops" in my opinion anyway though.
 
@derp well I suppose you can't provide your own implementation if you have your own structure, can you?
 
It basically does the same thing.
 
11:25 PM
$array_or_countable suggests that you can make your tree implementation implement this "countable" thing
 
Friday payday. Whoop.
 
I stumble on understanding why the recursiveness is controlled by a parameter instead of simply being another function, though.
 
Ow noice. It's friday again. Moar booooze
 
@BartekBanachewicz E_PHP
 
@HamZa wut?
 
11:27 PM
@BartekBanachewicz you wonder? Because it is PHP. Not unusual :P
 
Yes I worked hard on getting php out of my brain, ecosystem and life basically.
 
@BartekBanachewicz I wonder why we provide the functionality at all
 
haha
 
but hey since I am kind of going back to using embedded C it can't be worse right
 
:)
 
11:28 PM
@PeeHaa Because count uses the class's implementation of countable, the 2nd parameters isn't always implemented/respected.
 
@BartekBanachewicz 3v4l.org/LRvkb
 
I have this simple rule: If I never used some functionality in the standard library, then it doesn't belong there :)
 
Agreed 100%
 
Thats... really all it's doing.
 
my use case or GTFO
 
11:29 PM
@DanLugg yeah but I mean can you apply count on your structure generically?
 
If you implement Countable
 
@NikiC a bold statement. I'd say a lot of that is a question of style.
@DanLugg it's an interface?
 
@BartekBanachewicz Well it sometimes seems like it also works / worked the other way around. If a single person had a use case for it at any point in time. It is in php
 
aside: I still have to educate people about count($string) once a month
 
@BartekBanachewicz Yes.
 
11:31 PM
@Leigh what's there to educate about?
@PeeHaa I'd say because of #2 you get annoyed by #1.
 
@BartekBanachewicz 3v4l.org/NDfOA
 
@BartekBanachewicz it doesn't do what amateurs think. run a var_dump(count('ab')); for yourself.
 
@DanLugg Is taking the mode parameter verified by the compiler?
 
@BartekBanachewicz What do you mean? It's an interface constraint.
So, yes?
 
so every data structure has to account for the count being possibly recursive?
 
11:35 PM
If it's countable? Yes, though most people don't in practice (from what I've seen)
 
No, I don't think we support the recursive option in Countable
 
@DanLugg so you just take the parameter and ignore it?
 
we had it for a short time in 5.6, but it was reverted
 
4 mins ago, by Dan Lugg
@BartekBanachewicz http://3v4l.org/NDfOA
Oh, was it?
 
@DanLugg ... so?
did you look at the version numbers?
 
11:36 PM
@NikiC wait so how is count specified?
 
@NikiC Well yea, I didn't know it was reverted in 5.6 though
 
@BartekBanachewicz Countable::count(void)
 
The docs say otherwise php.net/countable
 
5.4 was kinda awhile ago, even now.
 
@NikiC so this parameter is now completely gone?
 
11:37 PM
@cspray It looks like the docs were updated, but not reverted when the change was reverted
it was pretty late in the release cycle
 
Ah, ok
 
@BartekBanachewicz yes. for all intents and purposes it was never there
 
ok
22 mins ago, by PeeHaa
OMFG TIL count() has a recursive parameter :O
so this ^ should be changed to had
 
:-P
 
@BartekBanachewicz No, the count() function still has it
for array use
 
11:39 PM
@BartekBanachewicz not the same thing ;)
 
@NikiC wait what count function
 
damn stupid language keyboard settings
 
you just said count is defined in Countable
 
@NikiC That might be noteworthy for the BC section of 5.6 then, I'm not seeing it anywhere.
 
@BartekBanachewicz There is Countable::count() and count()
 
11:39 PM
guys, you are all totally confusing everything here
There's a count() function
And there's Countable::count()
The former has a recursive parameter, the latter hasn't
The latter never had it, so there's no BC break ^^
 
Yes, Countable::count is invoked when count() is passed a Countable. And that arg was passed too, for 5.4 - 5.5
 
so how does ::count behave when called on a Countable? Is the parameter ignored?
 
@NikiC aside: new GMP(); should be new GMP([string number, int base]), whaddaya think?
 
@BartekBanachewicz yes
 
But the deprecation isn't mentioned here ca1.php.net/manual/en/migration56.changed-functions.php
 
11:40 PM
 
^^ Yea, that guy.
 
While we're counting
 
@DanLugg What deprecation?
 
@NikiC uh. I really don't get why it's a single function, then
 
@DaveRandom :-)
 
11:41 PM
Of the Countable::count $mode parameter.
 
> Oh hey it's a function that takes an array or a countable and a parameter, but if you pass in a countable this parameter is ignored.
 
If it was removed, then that is now a BC break since 5.4.
 
@BartekBanachewicz So you can do count([1, 2, 3]) without needing to implement an object to do so
 
@BartekBanachewicz Basically history reasons. the recursive parameter was a thing before Countable was a thing
 
@cspray implement what object.
 
11:42 PM
and adding it for countables in general is pretty stupid because everything will have to handle it even though nobody uses it, ever
 
Wait, @NikiC, I'm drunk.
 
@DanLugg yes, yes you are
 
@NikiC but removing the param from countable in 5.6 is as much of a breaking change as removing it from count, no?
 
@NikiC I saw the 5.4 - 5.6, but read the ng output in my 3v4l
 
and the fact that count has that parameter is the very problem.
 
11:43 PM
@BartekBanachewicz Countable never had such a parameter
 
3 mins ago, by Dan Lugg
Yes, Countable::count is invoked when count() is passed a Countable. And that arg was passed too, for 5.4 - 5.5
 
@BartekBanachewicz Some of us get wasted and still think we can participate in constructive discussion.
 
it only had the param in a pre-release version, but it was removed later
 
^^
 
@NikiC ah I see.
 
11:44 PM
Well, now that i've assed that discussion, I'll be going to get another beer
 
@BartekBanachewicz I misunderstood your statement. Just ignore me.
 
@NikiC ...because it has basically no sane use case
 
can arrays have references to themselves inside?
 
Yes
 
that would make that function go into infinite recursion, then? :)
 
11:48 PM
not according to the manual, but who knows if it's accurate "Caution
count() can detect recursion to avoid an infinite loop"
 
"who knows if it's accurate"?
how can it not be?
 
@BartekBanachewicz It'll spit out a warning and return false
 
@NikiC wait why "false"?
 
Apparently not false though
 
11:49 PM
it was supposed to return a number
 
ah yeah sorry
it just won't count the recursive branches
 
I don't understand int(3) there
lol. hhvm segfault
 
134
Q: I want to delete the [internet]

BraiamInternet, depending who you ask, means different things in different contexts. It is a vague concept where everyone has their own idea of what exactly it is, and the official definition is too broad to be useful. The questions tagged with internet are almost about everything, from git to networki...

 
oh also count('ab') returned int(1) for me if I can use that 3v4l thing properly
looks like it's somewhat broken
is it a bug?
 
[root@internet]$ rm -rf /
 
11:52 PM
No
count is for arrays, not strings
 
count -> strlen
 
which is why I said, I have to school people about it monthly
 
@Leigh isn't string an instance of implementation of Countable?
 
dafuq
 
count should really throw an error for the non-array/object case
 
11:53 PM
what language you using boy?
 
imho
I think the logic for 1 is that count((array) $str) would be 1
 
string... instanceof.... mind blown
 
which kinda somehow makes sense
but it more likely to be a programming mistake
 
14 mins ago, by NikiC
And there's Countable::count()
 
@NikiC only in PHP :-P
 
11:54 PM
@Leigh tell them they need to str_split before count...
 
@BartekBanachewicz Objects implement interfaces. Strings aren't objects ;9
 
@Leigh I understood that Countable is an interface specifying count. So I'm asking if string type implements that interface.
 
@BartekBanachewicz is_object($string)
 
@NikiC so what are they? o.O
 
11:55 PM
They are strings
 
completely separate thing?
 
@BartekBanachewicz They're strings
 
They are primitives
 
btw, I'm like the House of PHP, I'll be a dick before I'm ever helpful
 
Are you a Java developer by any chance? @BartekBanachewicz
 
11:56 PM
morning room
 
@BartekBanachewicz think of it like java
or c++ for that matter, really
 
@DaveRandom It probably counts 1 past the recursion; 1 + 1 (recursion detected) + 1
 
ola Yack
 
you should know all about not everything being an object ;)
 
I hope they know what they are doing...
 
11:56 PM
@Leigh Do I really talk that much? :)
 
481
Q: Feedback requested: Runnable code snippets in questions and answers

HaneyToday we're proposing a new feature to the Meta Stack Overflow community: Stack Snippets. What do Stack Snippets do? Stack Snippets make code blocks runnable. Here's an example: alert("You can even do alerts"); .hello { font-weight: bold; font-size: 1.5em; } <div class="hello">Stack...

 
@BartekBanachewicz Maybe in languages that make sense.
 
@DaveRandom no.
 
@DanLugg I was thinking it was like: recurse into -> increment -> oh shit, get out, get out
 
@DaveRandom Java has primitive types as well ;)
 
11:57 PM
@NikiC C++'s std::string is a class, and instances of that class are objects.
 
@Leigh Yea, something like that.
 
@NikiC Yeh but String is not one
 
@BartekBanachewicz yeah, but int isn't a class
and char[n] isn't a class
and whatever else isn't a class
 
@BartekBanachewicz But this isn't C++.
 
in php, strings aren't a class
 
11:57 PM
except, maybe, for UString ^.^
 
IN PHP STRING COUNTS YOU
 
@webarto I know this isn't c++, that's why I am asking?
 
Not everything is an object, like Ruby.
 
and now we have PHP 5.6, where sometimes is_object($a >> $b) === true
 
Bit shift returns an object?
 
11:59 PM
wat?
 
Cool!
 
only if $a instanceof GMP
 
When you run out of bits, you get an instance of Bitless
 
PHP makes no sense to outsiders unpolluted minds
4
 

« first day (1412 days earlier)      last day (3539 days later) »