From 4da1d67eaf9d1d3ddf82603569a06f203e7de28d Mon Sep 17 00:00:00 2001 From: serg-meus Date: Mon, 14 Mar 2022 20:47:09 +0700 Subject: [PATCH] doc: update struct access modifiers --- doc/docs.md | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index c7d4d85696..80ffa05362 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), the attempt +to access it from another module will cause an error during compilation. +Immutable fields are readonly from anywhere. ### Methods