From d6eb6d5bae7d9a25514901de31574f422d534fdf Mon Sep 17 00:00:00 2001 From: serg-meus Date: Mon, 14 Mar 2022 23:38:36 +0700 Subject: [PATCH] doc: update struct access modifiers (#13734) --- doc/docs.md | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index c7d4d85696..94133b2a7d 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -2084,29 +2084,9 @@ __global: f int // public and mutable both inside and outside parent module } ``` - -For example, here's the `string` type defined in the `builtin` module: - -```v ignore -struct string { - str &byte -pub: - len int -} -``` - -It's easy to see from this definition that `string` is an immutable type. -The byte pointer with the string data is not accessible outside `builtin` at all. -The `len` field is public, but immutable: -```v failcompile -fn main() { - str := 'hello' - len := str.len // OK - str.len++ // Compilation error -} -``` - -This means that defining public readonly fields is very easy in V. +Private fields are available only inside the same [module](#modules), any attempt +to directly access them from another module will cause an error during compilation. +Public immutable fields are readonly everywhere. ### Methods