3 ms·
The strangest language 'feature' I've come across must be 'ticks' in PHP: > A tick is an event that occurs for every N low-level tickable statements executed b
by jperras 16y ago
The strangest language 'feature' I've come across must be 'ticks' in PHP:
> A tick is an event that occurs for every N low-level tickable statements executed by the parser within the declare block. The value for N is specified using ticks=N within the declare blocks's directive section.
( http://www.php.net/manual/en/control-structures.declare.php http://www.php.net/manual/en/control-structures.declare.php )
PHP is a hodgepodge of inconsistent APIs and general weirdness already, but I really did sit back and have a good WTF moment when I discovered this 'feature'. I have yet to encounter many people who have ever heard of ticks, let alone anyone who has actually implement functionality that depended on them. I've never seen something like that in Python or Ruby.
- deleted 16y ago[deleted]
- silentbicycle 16y agoIt's really not that strange - it's probably intended debugging & profiling code. It sounds like Lua's debugging hook (http://www.lua.org/manual/5.1/manual.html#lua_sethook http://www.lua.org/manual/5.1/manual.html#lua_sethook), which can run a callback every N vm instructions. I made a simple profiler by setting the hook to run every X ticks (typically 10,000), recording the call stack, and then seeing where most of the execution happens. If every other time you look at the vm, it's in the same place, then it's clearly a hotspot. I don't know of an equivalent in Python or Ruby, off the top of my head, but I'd be surprised if they weren't available.