Comments (7)
The correct syntax is
struct Foobar {
member int
}
fn (f mut Foobar) do() {
// method of pointer type receiver
println('I am foobar')
}
fn main() {
f := Foobar{}
f.do()// I assume f is type of "Foobar", but can treat as pointer type with implicit conversion ( like Golang )
}
from v.
(f mut Foobar)
instead of (f *Foobar)
I'll update the compiler so that (f *Foobar)
doesn't compile.
from v.
I assume f is type of "Foobar", but can treat as pointer type with implicit conversion ( like Golang )
This assumption is correct :)
from v.
OK, I understood.
ありがとうございました m(_ _)m
from v.
Fixed.
You should now get use (f mut Foobar) instead of (f *Foobar)
from v.
I have confirmed .
thanks a lot!
from v.
f is type of "Foobar", but can treat as pointer type with implicit conversion
I don't think letting pointers implicitly dereference is a good idea, and it seems to go against the simple philosophy of V:
mut i := 5
p := &i
i = p // confusing, should be an error
i = *p // OK
Edit: See #61
from v.
Related Issues (20)
- net: net.listen_tcp fail in -prod mode HOT 8
- x.vweb: add gzip compression support for static files
- Compile time generation not working for maps in structs HOT 1
- incorrect values in interface reflection HOT 1
- x.vweb: gzip middleware can't be used if os is imported HOT 2
- ORM: `update table set field=field+1` is broken HOT 1
- watch: excessive memory usage [6gb...] HOT 2
- error library 'atomic' not found HOT 1
- compile error: value `100000000000` overflows `u32` HOT 3
- C. type unknown HOT 1
- Compiler Bug raised when trying to compile my code HOT 4
- [x.json2] Add skippable struct fields @[json: '-'] HOT 1
- Confusing error message when using `is` with a constant rvalue HOT 4
- Data corruption when initializing struct with 2-dimensional array of structs as a member HOT 4
- Better error message for memory allocation in vplayground HOT 1
- vlib: http.Server: different behavior between prod and non-prod for *invalid* Response object
- Builder error: bad map usage
- Different markdown rendering for enumerated list in module documentation HOT 2
- toml.parse_file does not panic when the file is missing HOT 2
- Will vweb have built-in Api document generation tools
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.