This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| // | |
| // https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html | |
| // | |
| // self-referential definition | |
| // recursive definition | |
| // it's like linked list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Example(object): | |
| """A singleton not thread safe | |
| """ | |
| _instance = None | |
| @classmethod | |
| def instance(cls): | |
| if cls._instance is None: | |
| cls._instance = cls.__new__(cls) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; ---------------------------------------------------------------------------------------- | |
| ; | |
| ; In macOS land, C functions (or any function that is exported from one module to another, really) | |
| ; must be prefixed with underscores. | |
| ; | |
| ; The call stack must be aligned on a 16-byte boundary. | |
| ; | |
| ; And when accessing named variables, a `rel` prefix is required. | |
| ; | |
| ; nasm -fmacho64 hello_with_c.asm && cc hello_with_c.o && ./a.out |