[php-src] Issue #10919: Another approach to Generics and type checking in general

From: Date: Thu, 23 Mar 2023 21:29:50 +0000
Subject: [php-src] Issue #10919: Another approach to Generics and type checking in general
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243996@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10919 Author: Wuffz ### Description Hi! I have been looking around for a few weeks now, looking how to use generics and i just dislike code within comments or docblocks, wether, e.g. docblocks or comments. i try to avoid them unless for documentation or commenting ( that's what they where meant to be ) I do get why many oppose to the idea of implementing type erased generics, some types would be checked, others won't, that would absolutely be inconsistent. Here's another idea, It's a shot in the dark, but it could have some value. Why not remove all type checking in the jit compiler ? Why not 100% rely on a standardized static analysis? The jit compiler could except compiled working code. Static analysis should be standard on? This would have many benefits: - No accidental breaking code.. At this point, we can stil have some random source which is required somewhere containing a missing ; That would be a breaking change for an entire system, which was already broken to begin with... Using static analysis this could form an error to the log ( no need to break the entire system yet, maybe later in the future ) - A single standard for static analysis. Every IDE can adopt this. I think its good to adopt one of te best ones in the field, this could be voted for ? Or maybe even do it in C or another language, so the php engine can just run it in the background using pre-(op)cache ? - Speed. Removing typechecking from the engine itself would increase speed, no doubt about that. Add an option for bypassing the static analysis, at the time writing, this should be on by default, with errors to log, continue running when possible for backwards compatibility. but when disabling the static analysis before run time, and no time checking. that would verry well increase speed. - Might open other openings and aproaches for the future, to implement a lot faster. I am just thinking about this how to overcome a problem like this.. generics are wanted, especially for those who use static analysis and those who are using autocomplete like intellisense stuff. Also it would reduce a lot of redundant code. I am verry pleased to see your responses and insights. Thanks!

« previous php.bugs (#243996) next »