« first day (1646 days earlier)      last day (3285 days later) » 

12:25 AM
@LeviMorrison I defend the switch (true) { ... } pattern, so much so that I think switch { ... } should be a valid shortcut
There are specific circumstances under which its more readable to have a list of boolean pattern matching expressions
@LeviMorrison also, what's the scoop with union types?
 
@DanLugg E_TOO_BUSY
 
E_RFC_DRAFT?
 
@DanLugg Here. I think it is slightly out-of-date; can't remember.
It was written before the scalar types fiasco.
I think enums will be simpler and less controversial, which is why I am working on that first.
But, you can never know with internals.
 
Understandably, though unions will be fucking epic.
Native enums will be sweet though.
Hmm, so no union typedefs? Or has that idea developed since?
Because union Foreachable { array, Traversable } @LeviMorrison
 
@DanLugg It's orthogonal, to some degree.
For instance, if we allow function signatures:
 
12:40 AM
I have a huge list of words as an array split into different files (by first letter), and my script picks a random letter (to get one of the arrays). It then picks a random word from that specific array, but I want to check the entire list of words for anagrams. The reason my list is split into multiple arrays, each as their own file, is because the memory settings from my host won't allow the whole array to be include()ed at once. Is there a way to include() each file then remove it?
 
type Comparator = callable($a,$b): int;
type Foreachable = array | Traversable;

function sort(Foreachable $input, Comparator $c) {
    /* … */
}
 
tl;dr Can you include() then remove files for memory's sake?
 
Make sense?
 
Makes wicked sense :-)
All over that, it's like C# delegate definitions
 
I'm working on this presently:
enum Maybe {
        None,
        Some($t)
}
match ($Maybe) {
        case None:
                echo "None";
                /* unlike switch there is no fallthrough behavior */

        case Some($t):
                echo "Some($t)";
}
 
12:45 AM
@kaloncpu57 You could do something like:
 
inspired by rust (and some swift)?
 
<?php //file A.php

return array(
	"aardvark",
	....
)
and then get the words in A.php by doing:
<?php

$words = require("A.php");
 
@Rangad Basically all modern languages with enums :)
(Except Hack)
(They were lazy)
 
However, what you really want to do is just write a function that loads the words through the file functions like this php.net/manual/en/function.file.php - rather than abusing the include/require functions to load data.
 
Those were just the first two languages that came to mind ;) Do you plan validations that every case was covered?
 
12:47 AM
Then you can have much easier control over what variables are referenced, and so are held in memory.
 
@Danack So the first option won't take up too much memory? Also, for the file functions, would I store the list as .txt files or have a .php return a string list?
Oh, right! I can reassign $words to each list as I need it.
 
"would I store the list as .txt files or have a .php return a string list?" - you could store it however you liked.
but yes, probably just one word per line would be simplest.
 
Awesome, thanks! I didn't know about reading a file into an array.
 
@Rangad It's a question of: can that really be done in a dynamically typed, interpreted language?
 
@kaloncpu57 You could also do it one line at a time - php.net/manual/en/function.fgets.php
 
12:51 AM
Could your versions of enum be extended
 
@Rangad No.
Enums are implicitly final.
 
Make them nestable!!
 
And with blackjack!
 
And nested types are implicitly subtypes of the container
 
@DanLugg Yeah… no.
 
12:53 AM
Yeah... yea.
 
@Danack Oh, right. PHP is one of the languages that I'm still trying to "memorize" (to a reasonable extent) what built-in functions are available. Would reading each line for each separate check slow things down significantly? I have 128,985 words..
 
@DanLugg What language does this?
 
@kaloncpu57 Yeah, learning the standard library is probably more work than actually learning the language. It almost certainly wouldn't be noticeably slow. There are multiple levels of file-caching when reading files in systems. Operating systems are pretty good at reading files ahead of time, but also just the way hard-drives are implemented mean that the smallest physical read size is about 4kB of data.
Reading smaller pieces than that actually just gets completely cached, so isn't usually a problem.
 
None, er go, mayhaps we should :-P @LeviMorrison
 
12:58 AM
I've tried to emulate it in C# and it's a pain in the sphincter.
It "works" but it's like trying to emulate enums in PHP now
 
@Danack Awesome! Thanks for all of that. When I finish implementing this would you like to see what I'm doing, or do you care much? It doesn't look aesthetically pleasing I have to say..
 
Hacktacular. I dunno, I think it would be helpful in creating static associations
 
@samaYo "consolation"
 
Feel free to link it, I'm sometimes busy though. Or drunk.
 
Ever both?
 
1:04 AM
Well, it's working now aside from the anagram checker. It's just a simple little game that I've been making to help learn PHP.
 
@kaloncpu57 Cute. You have at least one word which doesn't apparently exist though "unket"
 
I just did a Ctrl-F search on the complete list and found "unket".. How were you looking for it?
 
It was shown as the word to guess.
 
maybe a strange form of a strange german word slipped into the list ;)
 
Oh! I see what you mean. It's on the list, but isn't actually a word. I use the English Open Word List for reference, so I'm definitely putting my trust in them.
 
1:17 AM
It appears in some scrabble dictionaries so someone thought it woild be a valid word.
 
@Rangad It's interesting to see how some (presumably) slang words would be put into Scrabble dictionaries.
 
It's not slang it's just an old dialect apparently
 
Nice finds. Etymology is pretty interesting to me.
 
hmm
I should do free PHP/FI 2.0 hosting
@LeviMorrison PLEASE DO
 
I think it requires a new construct, unfortunately.
 
1:27 AM
@LeviMorrison A way to do it would be to add a new kind of statement within switch
 
Or use match instead of switch.
43 mins ago, by Levi Morrison
match ($Maybe) {
        case None:
                echo "None";
                /* unlike switch there is no fallthrough behavior */

        case Some($t):
                echo "Some($t)";
}
Rust has switch and match, so that's precedented.
 
switch ($foo) {
    match [$x, $y, $z]:
        // do stuff
        break;
    match FooBar { foo: $x, $bar: $y }:
        // do stuff
        break;
    case Foo::Bar:
        // do stuff
        break;
}
 
(they don't use case in match, though)
In any case, I am working on getting this kind of thing to work:
enum Maybe {
        None,
        Some($t)
}
 
Cool
@LeviMorrison until we have destructuring, I suggest making this work:
switch ($foo->type) {
    case Foo::None:
        // blah
    case Foo::Some:
        // blah
}
Or something like it
 
You could use name():
switch ($foo->name()) {
    case "None":
        // blah
    case "Some":
        // blah
}
 
1:31 AM
You could. It's a little inelegant, though, switching over a string
though
Well:
 
@Andrea Not as good as pattern matching, no :)
 
switch (true) {
    case $foo instanceof Maybe::None:
        // ...
    case $foo instanceof Maybe::Some:
        // ...
}
But yeah
Some form of destructuring, or, better, pattern matching, would be great
@LeviMorrison we already have limited destructuring for arrays in the form of list(), I wonder if that can be extended
ooh
 
@Andrea I looked into this already.
 
oh?
 
It only works on numbered arrays, not named ones.
That doesn't mean it's impossible; just not easily cannibalized.
 
1:34 AM
It could be made to work on named ones
And it could be extended to objects, though not sure how typing it would work
 
@Andrea At least presently I was planning on subtyping the enum only on values that have properties.
That's how Java does it, anyway.
 
switch ($foo) {
    case list($x, $y, $z):
        // do stuff
        break;
    case list(->foo = $x, ->bar = $y):
        // do stuff
        break;
    case Foo::Bar:
        // do stuff
        break;
}
ooh
 
What visibility would you default $t to be?
6 mins ago, by Levi Morrison
enum Maybe {
        None,
        Some($t)
}
 
@LeviMorrison what, the properties?
or the class itself?
oh uh
Public.
It only really makes sense that way, you can't really hide information there
 
I was thinking private with read-only capabilities.
I don't feel strongly about that at all.
 
1:37 AM
switch ($foo) {
    case list($x, $y, $z):
        // do stuff
        break;
    case list Foo::FooBar(->foo = $x, ->bar = $y):
        // do stuff
        break;
    case Foo::Bar:
        // do stuff
        break;
}
@LeviMorrison Oh, I was thinking public-readable
It being guaranteed-immutable would be good
switch ($foo) {
    list($x, $y, $z):
        // do stuff
        break;
    list Foo::FooBar(->foo = $x, ->bar = $y):
        // do stuff
        break;
    case Foo::Bar:
        // do stuff
        break;
}
@LeviMorrison being immutable for now makes sense
If mutability is important, it can be added later
But you can't remove that
list(->foo = $foo, ->bar = $bar) looks OK, right?
Oh man, this would be so great for JSON!
current code:
switch ($segment->type) {
    case 'dot':
        imageFilledRectangle($image, (int)($segment->x - 1.5), (int)($segment->y - 1.5), (int)($segment->x + 1.5), (int)($segment->y + 1.5), $colour);
    break;
    case 'line':
        imageSetThickness($image, 3);
        imageLine($image, (int)$segment->from_x, (int)$segment->from_y, (int)$segment->x, (int)$segment->y, $colour);
    break;
}
new code:
switch ($segment) {
    list(->type = 'dot', ->x = $x, ->y = $y):
        imageFilledRectangle($image, (int)($x - 1.5), (int)($y - 1.5), (int)($x + 1.5), (int)($y + 1.5), $colour);
    break;
    list(->type = 'line', ->from_x = $from_x, ->from_y = $from_y, ->x = $x, ->y = $y):
        imageSetThickness($image, 3);
        imageLine($image, (int)$from_x, (int)$from_y, (int)$x, (int)$y, $colour);
    break;
}
 
1:53 AM
Hmm. I'm not sure what to store in the class const make enum values with properties work.
I was thinking an object with __invoke would work.
 
@LeviMorrison My suggestion: don't store anything
Or, well
 
Maybe::Some($value) <- that needs to work to make a value.
 
Make a method.
By the way
I was thinking about this before. I think it might make sense to make all members methods, regardless of whether they have extra info
Because then you can have:
Maybe::Some (type), Maybe::Some(...) (constructor)
Maybe::None (type), Maybe::None() (constructor)
switch ($maybe->type) {
    case Maybe::Some:
        // do something
    case Maybe::None:
        // do nothing
}
On the other hand, maybe that's not a good idea
I don't know.
 
It would just so happen that omitting () for enums that have no properties would work.
I can try it out, at least.
 
the problem is Maybe::Some would need to be some sort of pseudo-type or special value or what have you
and that's weird
 
1:57 AM
I don't have any better ideas at present.
 
I suppose you could do something very PHP:
Maybe::Some = "Maybe::Some" (ditto for None)
So for None you have to call a method to get the value
Which is inefficient, I guess... but it avoids any hackery
 
But then we have stringly typed stuff.
 
And it means the ones with and without properties work properly
But, hmm
@LeviMorrison Yeah.
@LeviMorrison another option:
Maybe\Some and Maybe\None
but then you'd need new Maybe\Some and new Maybe\None which is a bit weird
Though
You could have shortcut constructors on Maybe but... yeah that's really weird and would probably make Anthony start screaming about OOP principles :p
 
I need type constructors and types to be different things.
I think that's the answer.
 
Hmm
 
2:01 AM
Based on what I understand about Haskell that's how they do it.
 
In Haskell you have multiple constructors (Some, None), one type (Maybe)
In PHP you'd probably do Maybe::Some(...), Maybe::None()
 
search: type constructors haskell and hopefully you'll see what I mean.
 
Guys, could you recommend me a free editor or IDE for developing Wordpress IDE?
 
@EnglishMaster vim is the best WordPress IDE
 
I want autocompletion for HTML, CSS and template language of Wordpress
and syntax highlighting and error check
 
2:07 AM
And a pony?
 
@Andrea I wouldn't use Vim to develop something "personal" unless you are limited to use just Vim
 
@EnglishMaster why not?
vim does syntax highlighting
vim does autocompletion
 
Because that's like you prefer walk to work when you can simply take a bus
 
vim kills emacs
How so?
 
@EnglishMaster I think you underestimate vim .
 
2:09 AM
@EnglishMaster No, using an IDE is like taking the bus when you could learn to drive (learn vim). You have to put in quite a bit of effort initially (to learn vim or to drive), but long term it saves you time (and money in the case of the bus)
 
yeah but modern IDEs crushes all of them, they are only for servers or for impressing girls in your programming classes in college
 
modern IDEs are shit
 
@EnglishMaster You still underestimate vim.
 
@LeviMorrison The Force is not strong with this one.
 
Unfortunately there aren't many hot girls in IT so it's useless to even talk about impressing those girls.
 
2:10 AM
@Andrea Agreed. To the tiny avatar list.
 
Any Notepad++ plugins for Wordpress template development?
 
I thought you said you liked IDEs
 
...
 
I forgot to mention editors
too
But I just don't want to send myself back to stone age and use Vim again
 
2:13 AM
@Andrea So… did you mean something like this?
class Maybe {
        const None = NULL;

        static function None() {
                return self::None;
        }

}
I just mean having a constant and a method for each enum value.
 
@LeviMorrison Almost, yeah.
Though None would work more like this:
 
I'd just write code on a piece of paper and transfer that into computer instead, if I was so serious about going back into time.
 
Obviously null isn't of type Maybe.
 
class Maybe {
        static function None() {
                static $none;
                return $none ?? ($none = new self("None"));
        }
}
(we should really add ??=)
So there's still a single instance of None, it'd just be retrieved/created by the constructor
 
@Andrea Are you girl btw?
 
2:16 AM
@EnglishMaster Yes.
Wait. I may have had a great and/or terrible idea
new Maybe::None
new Maybe::Some($foo)
 
I'm looking at the anonymous class RFC but some things are still shaky.
 
Can I ask you something non-related to PHP?
 
class Maybe {
     const None = __secretEnumMaybe__Noneclasswithabetternamethanthis::class;
}
 
and plz don't kick me afterward
 
@EnglishMaster No.
 
2:17 AM
ok nvm
 
@LeviMorrison Wouldn't even need to be an anonymous class
Think about it.
String typing. Sounds awful, yes, but it works out here
 
I can make a zval hold a zend_class_entry* but what do I do in user-land?
 
class Maybe {
     const None = Maybe$$None::class;
     const Some = Maybe$$Some::class;
}
 
Ah, back to stringly typed.
That won't work as types in parameter and return declarations.
 
Well, it shouldn't
Maybe should be your typehint
not some member of Maybe
 
2:20 AM
But if Maybe::None is a string then it won't validate against a Maybe
 
I mean, that makes as much sense as function foo(true $bar)...
@LeviMorrison But you don't pass a None.
You do new Maybe::None
 
I don't think that will go down well for these cases:
enum Color { Red, Blue, Yellow }
I guess in these cases you can store an instance instead of a string.
 
@Andrea Oh, it'll work internally :)
Oh, wait, I see.
 
hmmm
 
2:23 AM
It failed on the new syntax, not the ::class part that I thought it failed at because I read it too quickly.
 
It took a while to make all of the .txt files, but the anagram checker works again. Now if you enter a possible word that isn't THE word you're looking for, it will tell you exactly that.
 
final class Maybe {
        const None = new Maybe(){};
        const Some = 'Maybe::Some';

        static function None() {
                return self::None;
        }

        static function Some($t) {
                $class = 'Maybe$$Some';
                return new $class($t);
        }
}
// works because internal magic voodoo
class Maybe$$Some extends Maybe {
        private $t;
        public function __construct($t) {
                $this->t = $t;
        }
        public function __get($name) {
                if ($name === 't') {
                        return $this->t;
                }
        }
}
@Andrea I know it's abominable but it might actually work.
 
I guess, just
...yuck
 
how Maybe::None and Maybe::Some are completely different
 
2:29 AM
The way I did it above has two advantages:
constant Maybe::None doesn't need to be instantiated to pass the Maybe type check
constant Maybe::Some won't pass Maybe type check; has to use the static function to instantiate one.
 
hmm
final class Maybe {
        const None = new Maybe(){};

        static function Some($t) {
                $class = 'Maybe$$Some';
                return new $class($t);
        }
}
 
Yeah, I guess the constant Some is unneeded.
 
and the function None is unneeded
If we need to check types, well, strings do work
they're ugly, but
 
Right.
 
here's the thing
    function foobar(Maybe $foo) {
        switch ($foo->kind) { // maybe?
            case "None":
                // ...
            case "Some":
                // ...
        }
    }
We actually know here that $foo is a Maybe
So checking by the kind by string name kinda works
 
2:34 AM
Works until we have pattern matching.
 
Yes.
 
So for this to work I need a few things:
1. I need to be able to create zend_class_entry's that don't go into the symbol table.
(I suppose it can go it; just needs to be impossible to instantiate in user-land)
 
No, do put it in the symbol table
just give it an illegal name
 
2. I need to be able to extend a final class.
 
That way it's reflectable
I suggest Maybe::Foo
It can have a private constructor
 
2:36 AM
3. I need to be able to create these static constructor functions at runtime. I dread this part.
 
@LeviMorrison Nope
@LeviMorrison __callStatic
 
@Andrea I still have to implement that somehow.
It's the same issue.
 
@LeviMorrison that's pretty simple though
it'd be identical code for any and every enum
 
Incorrect.
 
How so?
 
2:37 AM
I don't want to use ... for parameters.
I want to generate a correct n-ary function.
and include type checking
 
Ah.
Hm
 
So given something like this:
 
@LeviMorrison generate a function and point it to the same internal function ;)
PHP gives a function enough context they could share an implementation, I reckon
 
I can probably use an internal functions I just need duplicate then modify the arginfo.
 
right
also, I've suggested it before, but I think you could do constants not by allowing objects to be a constant, but by having something like __getConstant (internals-only, ofc)
 
2:40 AM
enum Maybe {
    None,
    Some(type $t)
}
 
guys, is there any design patterns you must keep in mind when you are writing a template for Wordpress?
 
then the Maybe::Some function will have type $t for it's parameter list.
 
final class Maybe {
        const None = new Maybe(<magic>);

        static function Some(type $t) {
                return new "Maybe::Some"($t);
        }
}

final class "Maybe::Some" extends Maybe {
    public $t;
    public function __construct(type $t) {
        $this->t = $t;
    }
}
@LeviMorrison I daresay that having a class extend a final class might not actually be checked in the Zend Engine, or if it is, you can probably make Maybe non-final, then finalise it after creating its subclasses
 
Finalize after subclass is what the Java bytecode does.
Dunno how I'd do that in ZE
 
hah
@LeviMorrison hacks
main problem is opcache
but it's flipping a bit, so.
Also
 
2:43 AM
Opcache fails on my current patch with no magic wonkery.
 
you want an internals API for enums too
 
Need to figure that out still.
As in, it fails with an empty enum decl (no values).
 
huh
 
So this:
enum Maybe {
        None,
        Some(type $t)
}
Translates roughly to:
final class Maybe {
        const None = new Maybe(0, "None"){};

        public readonly $ordinal;
        public readonly $name;

        protected function __construct(int $ordinal, string $name) {
                $this->ordinal = $ordinal;
                $this->name = $name;
        }

        static function Some(type $t) {
                return new "Maybe::Some"($t);
        }
}
// works because internal magic voodoo
final class "Maybe::Some" extends Maybe {
        public readonly $t;
        protected function __construct(type $t) {
 
Guys, I'm not trying to troll but people immediately assume I'm about to troll when I try to have some conversation.
 
2:50 AM
@Andrea Look… okayish?
 
yeah
 
enum Maybe {
        None,
        Some($t)
}
is what it would actually be, until we maybe get generics
If we did, it could be extended like so, I hope:
enum Maybe<T=mixed> {
        None,
        Some(T $t)
}
 
Meh, that's generics stuff.
Not touching that at present.
 
Right.
 
2:52 AM
But yes, that'd be lovely.
 
I think it's really important that if PHP ever does get generics, they must be retrofittable to existing classes without breaking things.
and it'd also be in keeping with the PHP spirit that way, too
Being able to do both List and List<int> would be awesome
 
@Andrea So it looks more like this:
final class Maybe<T> {
        const None = new Maybe(0, "None"){};

        public readonly $ordinal;
        public readonly $name;

        private function __construct(int $ordinal, string $name) {
                $this->ordinal = $ordinal;
                $this->name = $name;
        }

        static function Some(T $t) {
                return new Some($t);
        }

        final private class Some extends Maybe {
                public readonly $t;
                private function __construct(T $t) {
 
3:19 AM
cool.
@Jimbo DAMN YOU ARGH
@LeviMorrison yeah, which has inspired me now
 
@LeviMorrison what happened to the RFC?
😱
 
@marcio Nothing; still unmerged as far as I can tell.
 
alpha is looming, will it be on PHP7? cc @JoeWatkins
nah, timeline is totes ambiguous. No despair.
 
4:14 AM
> Ceylon inherits syntax from Java. If you have experience with Java already, Ceylon should be pretty familiar to you. Let’s take a look at a simple Ceylon problem
void hello() {
    print("Hello, World!");
}
My reaction:… a free-standing function?!?! I thought you said this was like Java?!?!
 
 
1 hour later…
5:25 AM
Guys, I have a question about possessive. If a singular noun ends with s or es, like Moses, Isis or Charles, how do you add 's?
In other word, describe possessive of those words?
 
5:58 AM
@marcio needs some work before it can be merged ... will be doing it next week
 
@EnglishMaster Moses', Isis' or Charles'
 
6:36 AM
56
Q: What is the correct possessive for nouns ending in "‑s"?

kiamlalunoWhat is the possessive of a noun ending in ‑s? Are these both right, or is the second one wrong? the boys' books the boss' car

 
7:32 AM
@KamranAhmed What is your rate?
 
@EnglishMaster 20$/hour
 
what about $9/hour
 
@KamranAhmed ok but please don't spam in every room
 
@EnglishMaster depends upon the project, we can discuss. How about skype?
 
what?
 
7:35 AM
Do you have skype? Mine is kamranahmed.se. It would be better, if we discuss this stuff there.
 
Can you develop a program that can find a guy who can work for me $8 dollars then ask him to update the program to look for $7 dollars one and so on?
 
@EnglishMaster You really have to troll him?
 
I'm very curious about how he is going to build it.
 
8:06 AM
@EnglishMaster what's your problem? He seems legitimate
 
nothing
 
Anonymous
moaring
 
8:44 AM
mornin'
 
8:58 AM
 
morning
So a friend of mine needed to clean up a computer he got from someone. He suddenly found java code in the windows registry.
 
 
1 hour later…
10:00 AM
.. that point when you read manga an suddenly realize: "waaait a minute, this is a fucking harem, isn't it"
well, at least the lead character is not a cardboard cut-out
 
10:16 AM
@NikiC by the way… I sometimes need to resort to get_defined_vars() because isset() doesn't work. Especially in cases where I extract()'ed something [for template mainly]
But I agree… needless to rediscuss that topic.
 
10:34 AM
I just learned about the old_function keyword in PHP 4...
 
10:51 AM
is it correct that i don't have any zend.assertions reference in the php.ini ? is it assert.active?
 
is 1 aws micro instance enough to run a personal blog
?
 
uh looks like the php.ini files in master aren't very updated
short_open_tag = Off
 
@Worf that's fine
 
i thought this was always On and not disable-able
 
that's just <?, not <?=
<?= is always on.
 
10:55 AM
oooh right right
> Note: **zlib.**output_handler must be empty if this is set 'On' !!!!
 

« first day (1646 days earlier)      last day (3285 days later) »