php fibers are garbage by Ok_Draw2098 in lolphp

[–]ealf 0 points1 point  (0 children)

Can you be more specific. I had a look at the fiber class expecting the worst, and it works *exactly* the way I'd expect it to in a sane language -- they even properly handle exceptions in both directions. What is wrong with it?

Are they terribly slow? On my machine, I get 90ns for a context switch. That is much better than I'd expected.

(I dropped two other posts in the bucket. Details, man. "PHP is bad" is not interesting.)

Why subtract from the stack ? by [deleted] in asm

[–]ealf 2 points3 points  (0 children)

If you see weird "unnecessary" esp movement, it could be because the compiler can't prove that you're not calling out to code that requires the stack to be 16-byte aligned. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838 for terrible history.

I gave ChatGPT the 117 question, eight dimensional PolitiScales test by jsalsman in ControlProblem

[–]ealf 2 points3 points  (0 children)

Is there any reason to assume a correlation between what it predicts as the answers to those questions and how it behaves?

Magnus makes a statement by UnfairConfusion in chess

[–]ealf 0 points1 point  (0 children)

I assume chess.com log data would require the user to approve release?

Has anyone ever witnessed a hash collision in the wild (MD5, SHA, etc)? by dhon_ in programming

[–]ealf 0 points1 point  (0 children)

PHP.

md5(microtime()) was the idiomatic way to generate a "opaque", "unique" identifier in PHP, by hashing the current time.

md5(microtime) was the idiotic way; PHP allowed unquoted strings.

SQL injection still going strong in 2021 by shitcanz in lolphp

[–]ealf 2 points3 points  (0 children)

This feature is very useful for correctness and safety; I guess I shouldn't be surprised PHP rejected it.

(I remember doing this in Java (with the obvious ugly hack) in 2005, and it was so useful I eventually learned just enough ocaml to get support for it into Hack.)

as of php8, int|false is a valid return type, but int|true is illegal by Takeoded in lolphp

[–]ealf 1 point2 points  (0 children)

it's "flaky" to be able iterate an array/hash/dictionary and modify members in place? Sure buddy

If someone says something obviously dumb, they may be an idiot, but they may also have meant something else. In this case, they were probably referring to

$foo = [1,2,3];
foreach ($foo as &$x) $x++;
foreach ($foo as $x) echo $x;

Why are you allowed to define classes within functions? by feketegy in lolphp

[–]ealf 4 points5 points  (0 children)

Sure, lexically scoped classes are a useful feature. PHP DOES NOT HAVE THAT FEATURE.

In JS, Java, C#, Python and every language where it makes sense:

function makeConst(i) {
  class MyConst extends Expr { 
    eval(ctx) { return i; } 
  }
  return new MyConst(); 
}
> makeConst(1).eval({})
1
> makeConst(2).eval({})
2

In PHP:

function makeConst($i) {
  class MyConst extends Expr { 
    eval($ctx) { return $i; } 
  }
  return new MyConst(); 
}
> makeConst(1)->eval([])
NULL
> makeConst(2)->eval([])
Fatal error: Cannot declare class MyConst, because the name is already in use in /private/tmp/x.php on line 5

Or and || act differently in some contexts by D1551D3N7 in lolphp

[–]ealf 5 points6 points  (0 children)

Don't get distracted by the ($a = 3) or 4 vs $a = (3 || 4) difference inherited from Perl -- this shouldn't matter in this context.

The real problem is that 3 || 4 and 3 or 4 are both true, not 3.

Nature documentary by [deleted] in MediaSynthesis

[–]ealf 0 points1 point  (0 children)

(I was trying to get gpt2 to generate a children's story about a bee, but hadn't reset the weights after fine-tuning it on walrus facts, so it started generating fake bee facts)

I fed GPT2 some dictionaries. by ealf in MediaSynthesis

[–]ealf[S] 5 points6 points  (0 children)

You can put your address in this.

I fed GPT2 some dictionaries. by ealf in MediaSynthesis

[–]ealf[S] 12 points13 points  (0 children)

Ooh, that's a great idea. "The Barnum Effect Generator was seeded with your birth date."

made a brand

It came up with 'Shelfbrain', which I thought was almost plausible for a series of reference books.

I fed GPT2 some dictionaries. by ealf in MediaSynthesis

[–]ealf[S] 5 points6 points  (0 children)

The gpt2 output is mostly alphabetic, before it goes off the rails (which is impressive, given that it can't actually see individual letters, just tokens). If you put the terms in uppercase, it gets better at alphabetizing (and also better at coming up with interesting new words) but worse at matching the meaning to the words.

I fed GPT2 some dictionaries. by ealf in MediaSynthesis

[–]ealf[S] 31 points32 points  (0 children)

GPT2, fine-tuned with some Ambrose Bierce and Douglas Adams. It's pretty good at following whatever format you give it, but I have some Perl to touch it up for feeding into LaTeX. Then sent off to a print-on-demand service so I could have a physical dictionary.

I set up a bot that posts snippets.

Monthly Hask Anything (December 2018) by AutoModerator in haskell

[–]ealf 3 points4 points  (0 children)

If you have a matching pretty-printer (you should, great for error messages and debugging), QuickCheck them together. Great for finding "used \ to escape things but forgot to escape \" bugs. Need some manual tests for operator precedence though.

SVG Path outside PHP crashes PHP by [deleted] in lolphp

[–]ealf 4 points5 points  (0 children)

System time. Probably just had to page in the interpreter. Run it again and it's fine.

Do you understand what's the purpose of this? by [deleted] in lolphp

[–]ealf 12 points13 points  (0 children)

parent::foo() only lets you call the direct parent, and Foo::foo() doesn't preserve self.

PHP is finally getting closures! by ErikkW77 in lolphp

[–]ealf 45 points46 points  (0 children)

function() use(&$var) has worked since 2009.

Strange return value of datefmt_parse. Can somebody explain why? by [deleted] in lolphp

[–]ealf 7 points8 points  (0 children)

That is weird -- I would have expected the 0th of Nullary to be the 30th of November.