From b9bd296adca43d796dbdbcc47beea68477b8618a Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 9 Jun 2020 22:40:36 +0200 Subject: [PATCH] doc: attributes --- doc/docs.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 0037d99734..9b457e1fe9 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -79,9 +79,11 @@ you can do in V. Hot code reloading Cross compilation Cross-platform shell scripts in V - Appendix I: Keywords + Attributes + + Appendix I: Keywords Appendix II: Operators @@ -1937,6 +1939,36 @@ Or just run it more like a traditional Bash script: On Unix-like platforms, the file can be run directly after making it executable using `chmod +x`: `./deploy.vsh` +## Attributes + +```v +// calling this function will result in a deprecation warning +[deprecated] +fn foo() {} + +// for C interop only, tells V that the following struct is defined with `typedef struct` in C +[typedef] +struct C.Foo { } + +[ref_only] // +struct Window { +} + +// V will not generate this function and all its calls if the provided flag is false. +// To use a flag, use `v -d flag` +[if debug] +fn foo() { } + +fn bar() { + foo() // will not be called if `-d debug` is not passed +} + +// declare a function with WINAPI +[windows_stdcall] +fn C.WinFunction() +``` + + ## Appendix I: Keywords V has 23 keywords: @@ -1964,7 +1996,6 @@ pub return struct type -var ``` ## Appendix II: Operators