Posts

Mixed types checker function to allow calling function with specific type

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box; } 0 I am basically trying to create "checker" function and based on the result of that function, call another function. This another function can only accept single type. The checker function should "filter" unwanted types. Here is an example: class A {} class B {} const checkB = (entity: A | B): boolean => { return (entity instanceof B) } const execute = (b: B) => { console.log('executed') } const start = (entity: A | B) => { if (checkB(entity)) { execute(entity) } } const a = new A() const b = new B() start(a) start(b) However Flowtype does not like this a...

If the heap is zero-initialized for security, then why is the stack merely uninitialized?

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0; } 14 0 On my Debian GNU/Linux 9 system, when a binary is executed, the stack is uninitialized but the heap is zero-initialized. Why? I assume that zero-initialization promotes security but, if for the heap, then why not also for the stack? Does the stack, too, not need security? My question is not specific to Debian as far as I know. Sample C code: #include <stddef.h> #include <stdlib.h> #include <stdio.h> const size_t n = 8; // -------------------------------------------------------------------- // UNINTERESTING CODE // -------------------------------------------------------------------- static void print_array( const i...