Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add article "An introduction to V" #2

Merged
merged 3 commits into from Jul 15, 2019

Conversation

Projects
None yet
4 participants
@Skn0tt
Copy link
Contributor

commented Jul 4, 2019

I wrote a small article that gives a short introduction to the design decisions made in V.
As V is a very promising project, I'd be happy to see it included here! :D

@whoizit

This comment has been minimized.

Copy link
Member

commented Jul 4, 2019

just notice, you should update the article

  • not cd v/compiler; make, but cd v; make
  • you no longer need to wrap everything in fn main () {}
  • HTTP package which just calls cURL under the hood - It's not clear. This is relevant only for the mac part of the code on the moment
@medvednikov

This comment has been minimized.

Copy link
Collaborator

commented Jul 4, 2019

These are valid points :)

@Skn0tt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2019

just notice, you should update the article

  • not cd v/compiler; make, but cd v; make
  • you no longer need to wrap everything in fn main () {}
  • HTTP package which just calls cURL under the hood - It's not clear. This is relevant only for the mac part of the code on the moment

Thanks a lot for the heads-up 😄
I updated the article to include your points.

Apparently, the location of the Makefile changed during the last week.
My local copy of the repo still had it in /compiler... V is moving fast 🚀

@ntrel

This comment has been minimized.

Copy link

commented Jul 5, 2019

@Skn0tt

  • I agree that V's http.get should be changed to return an optional. There are some other functions that should too, e.g. string.index().
  • Note that math.sqrt does not return an optional, I think this is acceptable as correct code should never pass a negative argument. Otherwise it forces a check on the result when the programmer should have checked the input instead.

@medvednikov medvednikov merged commit f7658d0 into vlang:master Jul 15, 2019

@ntrel

This comment has been minimized.

Copy link

commented Jul 15, 2019

@Skn0tt can you fix this please:

// this is the way it works in V:
result := math.sqrt(-1) or {
  // ... handle your error
}

sqrt returns f64, not an optional. With a negative argument the result is NaN.
https://vlang.io/pkg/math

@Skn0tt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 15, 2019

You’re absolutely correct, I chose a flawed example. I will edit the article once I get around to it (sometime later this week).

I was kinda busy the last week and I also kinda forgot about it - so sorry for not answering earlier.

@Skn0tt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 16, 2019

I just updated the post and replaced math.sqrt with the placeholder unsafe_function - which is better at illustrating my point, anyway.
I mentioned your advice in a foot-note (I hope you're OK with that 😄).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.