authorgravatar for 3405586+schmee@users.noreply.github.comJohn Schmidt <3405586+schmee@users.noreply.github.com> 2019-02-18 23:53:41+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-18 17:53:41-05:00
log99adda9df5a5ae6c16b60da6ba7d57fd2154b81c
tree7e73e11a12d86004b2954d46c54bece041299017
parent043090020f5052fdee0fffc02dc7ef379ea63fd0

Some function doc tweaks (#1961)

* Add docs for the inline function attribute * Remove outdated comment Seems like a leftover from when implicit returns were around. * Consistent terminology

1 files changed, 7 insertions(+), 2 deletions(-)

doc/langref.html.in+7-2
...@@ -3169,7 +3169,6 @@ const assert = @import("std").debug.assert;...@@ -3169,7 +3169,6 @@ const assert = @import("std").debug.assert;
3169// Functions are declared like this3169// Functions are declared like this
3170fn add(a: i8, b: i8) i8 {3170fn add(a: i8, b: i8) i8 {
3171 if (a == 0) {3171 if (a == 0) {
3172 // You can still return manually if needed.
3173 return b;3172 return b;
3174 }3173 }
31753174
...@@ -3193,12 +3192,18 @@ fn abort() noreturn {...@@ -3193,12 +3192,18 @@ fn abort() noreturn {
3193 while (true) {}3192 while (true) {}
3194}3193}
31953194
3196// nakedcc makes a function not have any function prologue or epilogue.3195// The nakedcc specifier makes a function not have any function prologue or epilogue.
3197// This can be useful when integrating with assembly.3196// This can be useful when integrating with assembly.
3198nakedcc fn _start() noreturn {3197nakedcc fn _start() noreturn {
3199 abort();3198 abort();
3200}3199}
32013200
3201// The inline specifier forces a function to be inlined at all call sites.
3202// If the function cannot be inlined, it is a compile-time error.
3203inline fn shiftLeftOne(a: u32) u32 {
3204 return a << 1;
3205}
3206
3202// The pub specifier allows the function to be visible when importing.3207// The pub specifier allows the function to be visible when importing.
3203// Another file can use @import and call sub23208// Another file can use @import and call sub2
3204pub fn sub2(a: i8, b: i8) i8 { return a - b; }3209pub fn sub2(a: i8, b: i8) i8 { return a - b; }