« first day (1718 days earlier)      last day (3224 days later) » 

4:00 PM
@ssube If your program needs to check for say, 10 / 20 values, it would get very nasty with if-statements.
 
@afonsomatos then you use a switch or a hash
 
or you use a chainable version, like Maps .add, and get the executing function with .get
I don't see the disadvantage here.
 
We will be replacing hardware for two of the #stackoverflow edge routers at about 18:00 UTC today. No service disruption is expected.
 
how does your little magical chainable switch handle fallthrough?
how does it fall through after a default, and if it doesn't, how exactly is it extensible?
how does it perform compared to a hash of functors?
 
@ssube The Maps example I gave, is an example of comparing values and retrieving functions. One could implement other solution similar.
 
4:05 PM
@afonsomatos your example doesn't answer any of those questions
 
It's still better than nested if-statements, arrays or object literals that only compare primitives, or switch-statements that syntactically, are not one of JavaScript's best, nor is its design.
 
it has the same semantics as a language switch (if you implement it properly) but is much, much slower and provides nothing the language did not already
 
Is it possible to restrict certain sublime text prefs to certain file types?
Oh herp
Nevermind
 
So, PHP7's bringing... anonymous classes.
 
awesomeeee
wait, what's that even good for?
 
4:18 PM
Like I know
> Performance Improvements with the addition of PHPNG engine.
 
Just finished Witcher 3. 9/10 would play again.
Now I can finally get back to coding after work
 
> Return type declarations, Scalar type declarations
 
so php just got some old feature of java 1.0
 
PHP is almost on the level of Java 10 years ago
 
4:23 PM
hah, beat you
 
:-(
 
> where anonymous classes are a part of a language they do find their way into many use cases
did they just say "we added that in, let's see what weird uses you come up with"?
 
// New Hotness
$pusher->setLogger(new class {
  public function log($msg) {
    print_r($msg . "\n");
  }
});
 
@JanDvorak It's a workaround when you can't directly reference functions
 
anonymous classes - poor man's anonymous functions?
 
4:25 PM
poor man's first-class functions
 
phph doesn't have first class functions? damn.
now i have a legit reason to not like it
 
I thought they did
 
@Luggage it kinda does
 
<?php
$conduit->pipe(new class implements MiddlewareInterface {
    public function __invoke($request, $response, $next)
    {
        $laravelRequest = mungePsr7ToLaravelRequest($request);
        $laravelNext    = function ($request) use ($next, $response) {
            return $next(mungeLaravelToPsr7Request($request), $response)
        };
        $laravelMiddleware = new SomeLaravelMiddleware();
        $response = $laravelMiddleware->handle($laravelRequest, $laravelNext);
        return mungeLaravelToPsr2Response($response);
FFS that's ugly
 
$foo = function($bar) { return $bar + 2; };
$foo(1); // 3
 
4:26 PM
huh, apparently not
7
A: Pass a function by reference in PHP

mačekThe problem with call_user_func() is that you're passing the return value of the function called, not the function itself. I've run into this problem before too and here's the solution I came up with. function funcRef($func){ return create_function('', "return call_user_func_array('{$func}', ...

 
The font is ugly, duh
 
@ssube these people are just bad at php: 3v4l.org/82tBc
 
@FlorianMargaine that's not hacky at all, using the function name
 
@ssube well, it's php
I did say "kinda does" :D
 
@ssube compared to variable variables? ^_^
 
4:34 PM
variable variables are awesome! For obfuscation, I mean
 
I find variable properties actually useful sometimes. Just like in JS.
 
I did actually do forEach(array("prefix1", "prefix2") as ...) once
 
I like that they aren't 'special' in JS. I find the [] syntax to be clear.
 
Hack doesn't support variable variables.
 
they aren't special in php either.
 
4:38 PM
@Luggage except you can't do that for the variable scope, just for properties
 
just that instead of [] it has {}.
 
ohh, yea, hm.
 
@JanDvorak in related flow, php has extract to introduce new variables in current scope.
most awesome feature ever.
 
the only thing JS would need for that is a way to get to variable scope.. locals["someVariable"].
 
extract isn't supported in hack either
 
4:39 PM
but that may not jive with the wy JS works
 
@uselesschien nobody uses hack except those who fake benchmarks for it.
 
${$_GET[k]} = $_GET[v] -- what could possibly go wrong?
 
aka those who made it.
@JanDvorak why would you do that?
 
Been a while since php.. what are the ${...} brackets doing?
 
4:40 PM
@AwalGarg Fuck hack, I'm going to write my web apps in assembly
 
@AwalGarg rage quit
 
webassembly
 
@SterlingArcher access variable by name
 
they are like parentheses for variable resolution. $_GET[k] is resolved, then a variable with that name is found
 
@JanDvorak meh
@uselesschien I wish I knew assembly :P
 
4:42 PM
@JanDvorak bracket notation basically?
 
for the variable scope
 
${$_GET[k]} = $_GET[v]
Object.assign(this, arguments);
 
@AwalGarg I know the basics. I can write simple programs, like sorting and stuff.
 
Assuming a GET request?
 
is that roughly similar?
 
4:42 PM
Or is that just a global scope method?
 
@Luggage not really
 
ok.
 
YAY I HAVE A VACATION DAY BUILT!
 
but old spidermonkey exposed magic objects providing access to local scope IIRC where you can do this kind of stuff in JS
 
#SavingForMexico
 
well _GET is passed in. you don't need to look at local varaibles for that
 
in JS, I mean
 
right
 
@FlorianMargaine That's masm..
 
4:44 PM
I'm ok with no being able to reflect over local variables. They should be used by the programmer, not by code.
we have all the dynamic variable access we want outside of that
I assume it would also allow some optimizations, too.
 
TBH I wish I'd be able to define functions with dynamic name in JS. Would be useful for libs I think.
 
posted on June 30, 2015 by Alex R. Young

Relae Relä (GitHub: joakimbeng/relae, License: MIT, npm: relae) by Joakim Carlstein is a library for fetching data from RESTful servers using React components. It can fetch data from a base URL, but can also filter data. If you've already injected JSON into the initial page load, then you can

 
@AwalGarg You can. You probably shouldn't though
 
@JanDvorak in strict mode? not really
 
you can export whatever you want.
 
4:47 PM
quick question about modernizr, I'm getting an error Uncaught TypeError: Modernizr.mq is not a function, I installed it with bower, mq should be available right? Am missing anything obvious?
 
that still won't modify function's name property
 
ohh, that name.
 
stack traces showing anon function 10 times are a pain to look at
 
Isn't that an argument for the name being pre-determined?
 
can't you just set it?
 
4:48 PM
read only
 
since named functions are in the local scope, that may be dangeroud to let them be dynamic.
 
window[prefix+"pi"] = function pi(){return 3.14}
 
var x = function Foo() { }; // still puts Foo in local scope
 
no?
 
@Luggage it doesn't
 
4:50 PM
!!> var x = function Foo() {}; Foo
 
@AwalGarg "ReferenceError: Foo is not defined"
 
except in old IE
 
ohh, i thoguht named functiosn were always put in scope. I stand corrected.
 
@Luggage say I have a function which returns a throttled function, or a memoized one. It is kinda sad I can't name it on the basis of the passed function.
 
hm.. yea. I see that.
 
4:51 PM
eval?
 
!!> var x = function Foo() { console.log(Foo); };
 
I won't lose sleep over it, though
 
@uselesschien "undefined"
 
@JanDvorak eww?
 
@uselesschien in response to your markdown question, honestly I don't know.. I'm using text-areas as they're less buggy and easier to use
 
4:52 PM
yeah I am not complaining about it just saying that these powers exist in PHP and they are nice to have. But easy to be abused, for sure.
 
inb4 PHP gets self-modifying code
 
and new Function() doesn't provide a way to name?
 
I mean, Python's decorators are kinda close, but...
 
One should not recommend PHP to beginners. In-fact PHP should be the last language of a person. When he is just about to die.
 
@Luggage No, it's an anonymous func
 
4:54 PM
sucks
 
@afonsomatos oh, that's okay
 
scrollbars are so ugly
 
functions created by Function won't give you much power anyways. Their scoping is limited and they don't create closures in their creation context.
 
IMHO, firefox's scrollbars are the only that look any good
 
It depends on your OS
 
4:56 PM
<- mac. no srollbars.
 
I mean have you noticed IE's scrollbars?
WTF??
 
Symbian -> no scrollbars
 
Android, no scrollbars
 
DOS, no scroll bars
 
intends to buy Android
@Luggage false
 
4:57 PM
@uselesschien imgur.com/hfTp21Q what do you think
 
ever heard of Norton Commander?
 
Linux, I choose whether I have scrollbars or not
 
Moto X. highly recommend.
 
^ (what @FlorianMargaine said)
 
and yes, i've heard of and used norton commander
 
4:58 PM
@Zirak it's taking so much time :D
Android is terrible :D iPhone is less terrible but also not particularly satisfying :D
 
@afonsomatos It looks so much better :D
 
@uselesschien I know right
 
If you actually care about mobile OSes, you're spending too much time on your phone and need to get a life, maybe some friends.
 
@BenjaminGruenbaum Indeed. Windows Phone rocks. </s>
 
@afonsomatos Mostly coz no comic sans
And you've added JSON export/import
 

« first day (1718 days earlier)      last day (3224 days later) »