-
Notifications
You must be signed in to change notification settings - Fork 65
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
[Proposal] Add support for ranges #418
Comments
I was going to ask you to expand on that, because when I see Dim s2 = s(2 To -3) would look like "Give me 2, 1, 0, -1, -2, -3" Still not sure about using the caret (or 'hat' as the C# proposal calls it), but is probably less likely to cause confusion than the minus sign. Otherwise, I can see the value. |
Then how about to put minus sign after the number? Dim c2 = s(2-)
Dim s2 = s(2 To 3-) |
hmm. Maybe, although it looks like there's something forgotten after the minus sign. I'm sure the C# peeps thought this all through, the caret is probably fine; I don't think there are that many people like me who associate it with XOR :) |
Maybe we should wait for others' ideas.😀 |
To me we already have the making of a range expression, in the current syntax. We just need a little additional syntax to handle;=
Clusive Ranges
Dim IncIncRange0 = first To last
Dim IncIncRange1 = first To In last
Dim IncIncRange2 = In first To last
Dim IncIncRange3 = In First To In last
Dim IncExcRange = first To Ex last
Dim ExcIncRange = Ex first To last
Dim ExcExcRange = Ex first To Ex last
|
We can simply perform exclusive by Dim ExcIncRange = first + 1 To last
Dim ExcExcRange = first + 1 To last - 1 and from start/end range can be written like: Dim FromStartRange = 0 To last
Dim FromEndRange = ^last To ^1 |
@Berrysoft
What if the range is return from a function call, it would good the have clusivity information at the call stie. Function F() As Range
Return In start To Ex finish Step step
End Function Especially when debugging hover over a range variable, would be possible to display bound clusivity.
|
@AdamSpeight2008 But the |
@Berrysoft I know that. |
@AdamSpeight2008 You're right, though I don't like to add new keywords...I prefer a simple proposal in order to make it more possible for LDM to approve, but we can continue discussing.😄 |
@AdamSpeight2008 That sounds more complicated. I originally want a syntax sugar for |
That messes with my OCD - brackets. must. match. :P |
Maybe that's why most languages doesn't use this syntax - the praser suffers.😄 |
@Berrysoft how about using "~" instead of "^"? Does it overlap with any other functionality? Or can "/" be used otherwise? Because I like the functionality you have given. |
@rrvenki whatever gets used, there will be someone who won't like it 😃 So on that basis, I'm tempted to recommend just doing what the C# team did. But then I slap myself and realise that whatever they've done VB could probably do better 😛 |
@rrvenki I like |
I hate it when I think a feature is in VB.net, when you try it out but you get errors because it is VB6 code. |
LOL. I always felt that it was a 'regression' that VB lost arrays with arbitrary dimension bounds instead of just (0..n). I get it was to make it easier to work with the arrays of other languages, but it was a loss for high-level programmers. That could actually be a useful thing to resurrect: arrays with arbitrary bounds. I would think that it wouldn't need to be a very fat wrapper around a standard array. |
edit: 'twas a dumb question. |
Actually I didn't propose to use parentheses, it's only the syntax of indexer. I think |
Sure enough, you didn't, I was just seeing things that weren't there. A good example of why you should never post things in haste without thinking them through fully! As you were. I was thinking about the range on its own, not a range of somethings, I think #25 is more the scenario I'm thinking of |
I think it is much more simple to write |
That's fine, but inside a query isn't so pretty, it gets a bit lost. Dim qx =
<div>
<%= From i In 1 To 10 Select <item ref=<%= $"{i}" %> /> %>
</div> Actually, is this really a different discussion than #25, or are they two sides of the same polyhedron? |
If you want it clearer, just put parentheses to ensure the priority like |
Fair point. Works for me. |
As C# is going to support ranges in 8.0, I think Visual Basic should also support it.
Considering the old grammer to declare array in VB6, we can support ranges like:
I chose
-
instead of^
at first, but then I changed my mind because the original indexer acceptsInteger
.The text was updated successfully, but these errors were encountered: