The V Programming Language

Simple, fast, safe language created for developing Volt, soon available for everyone.

Open source release in June 2019. Early access since April 15.
Install V from source in 0.5 seconds
wget vlang.io/v.c && gcc -o v v.c
1.9k

Allow "opt-in" mutable function parameters

Alex
Apr 15 · 3 min read
wdevore Apr 11 12:56
I am not sure I appreciate the idea behind immutable parameters on functions (i.e. partial purity).
Wouldn't this cause a lot of allocations and large return variables. This seems like it would slow V down during run time.

For example, If I had a function like:
```
fn (b mut baker) make_bread(cheese CheeseType, bread BreadType) CheeseType , BreadType {...}
```

Wouldn't an "opt-in" approach using `mut` allow the programmer more flexibility?
```
fn (b mut baker) make_bread(cheese mut CheeseType, bread mut BreadType) xyz {...}
```
medvednikov Apr 11 22:01
Yes, several people raised this concern.

The goal is to optimize this behind the scenes. If it turns out some cases are not optimizable, I'll allow it.
wdevore Apr 12 21:25
Cool. Thanks for the feedback.
medvednikov May 10 21:38
This has been implemented:

https://vlang.io/docs#recvs
Log in via GitHub to comment



Powered by vtalk, open-source blogging/forum software written in V