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 some explanations #10

Merged
merged 1 commit into from
Mar 9, 2019
Merged

Add some explanations #10

merged 1 commit into from
Mar 9, 2019

Conversation

ntrel
Copy link
Contributor

@ntrel ntrel commented Mar 5, 2019

  • Add some explanations.
  • Add TODO for documenting for loop break & continue.

BTW, the docs for interfaces here don't seem to be in master.

Add some explanations.
Add TODO for documenting for loop break & continue.
@ntrel
Copy link
Contributor Author

ntrel commented Mar 5, 2019

BTW other things I just saw that need documentation - go, lock ;-)

@medvednikov
Copy link
Member

Hi @ntrel
Thanks for you PR.
I'll be very busy in the next 30 hours with launching Volt for Linux and Windows.
I'll merge this a bit later.

user := repo.find_user_by_id(10) or {
eprintln(err)
return
}
println(user.id) // 10
user = repo.find_user_by_id(11)? <comment>// ? propagates an error </comment>
println(user.id) // 11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these lines so the statement? error propagation is documented under the Option types section.

fn (db DB) query_one&lt;T>(query string, id int) T? {
<comment>// Return a value of type T from the database, or an error.
// Implementation omitted...</comment>
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because seeing the signature seems helpful to understanding this example.

}

<comment>// This is a generic receiver function. V will generate it for every Repo instance it's used with.
// T is a member type of Repo, so it is in scope for this receiver function.</comment>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my understanding anyway ;-)
This code suprised me a bit. I would have thought that only members of r would be in scope for this function, not members of Repo. Or is T a member of r too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T is not a member, it's a type. I'll make it more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed T was exposed as Repo.T, but maybe V just makes it accessible for this function because Repo was mentioned as the receiver parameter and T is the template parameter for Repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand now, see #13.

@@ -266,7 +267,7 @@ <h2 id=strings>Strings</h2>
In V, a string is a read-only array of bytes. String data is encoded using UTF-8.

<p>
Strings are immutable. This means that the substring function is very efficient:
String contents are immutable. This means that the substring function is very efficient:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong with "strings are immutable"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings have length, and the length is not immutable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. It can't be modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so we can't append to a string to change it's length?

@@ -409,7 +410,7 @@ <h2 id=for>For loop</h2>
because with the latter it's easy to forget to update the counter and get
stuck in an infinite loop.


TODO: Break and continue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of things are missing, I don't wont to pollute the docs with TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough ;-)

@medvednikov medvednikov merged commit 6711386 into vlang:master Mar 9, 2019
@ntrel
Copy link
Contributor Author

ntrel commented Mar 10, 2019

Thanks for merging!

@ntrel ntrel deleted the patch-1 branch March 10, 2019 11:50
ntrel added a commit to ntrel/V that referenced this pull request Mar 10, 2019
Resolve some issues discussed in pull vlang#10.
medvednikov pushed a commit that referenced this pull request Mar 17, 2019
Resolve some issues discussed in pull #10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants