This pass has the job of enforcing memory safety. This is a subtle topic. This docs aim to explain both the practice and the theory behind the borrow checker. They start with a high-level overview of how it works, and then proceed to dive into the theoretical background. Finally, they go into detail on some of the more subtle aspects.
NOTE: This was first authored on 26 Feb 2014. Things may have changed since then.
C++'s templates could be seen as forming a duck typed, purely functional code generation program that is run at compile time. Types are not checked at the initial invocation stage, rather the template continues to expand until it is either successful, or runs into an operation that is not supported by that specific type – in that case the compiler spits out a 'stack trace' of the state of the template expansion.
To see this in action, lets look at a very simple example:
template
@mixin hocus { | |
&:hover, | |
&:focus { | |
@content; | |
} | |
} | |
// Before | |
E { | |
&:hover, |
fn once(f: Box<Fn()>) { f() } | |
fn twice(f: fn()) { f(); f() } | |
fn thrice<F: Fn()>(f: F) { f(); f(); f() } | |
// Inline definition of anonymous functions. Examples: | |
// l!(42;) | |
// l!(i32 := 42) | |
// l!(i: i32 := i + 42) |
javascript:(function(){if(location.href.indexOf('http')!=0){input=prompt('URL:','http://');if(input!=null){location.href='http://web.archive.org/web/*/'+input}}else{location.href='http://web.archive.org/web/*/'+location.href;}})(); |
ifeq ($(MAKECMDGOALS),me a sandwich) | |
.PHONY: me a sandwich | |
me a: | |
@true | |
sandwich: | |
@if [[ $$(id -u) == "0" ]]; then \ | |
echo "Okay."; \ | |
else \ | |
echo "What? Make it yourself."; \ | |
false; \ |
Any directory with __init__.py
is considered a package in Python.
Any python files inside a package is considered a module.
Modules contain functions and other bindings that is always exported.
If you are outside the package, and you want to import a module from a package:
Be careful if you are adding user to docker group. | |
1. As a root, create a file (owner root and group root) | |
$ touch /etc/foo | |
$ ls -l /etc/foo | |
-rw-r--r-- 1 root root 0 Dec 5 17:40 /etc/foo | |
2. Login as a non-root user belongs to docker group. In my example its user u1. | |
$ id |
#!/bin/sh | |
if pwd | grep /mnt/c > /dev/null; then | |
exec git.exe "$@" | |
else | |
exec /usr/bin/git "$@" | |
fi |