Open retsyo opened 3 years ago
Omg. Why? I believe it's good to be BASIC so people who work with VBA are immediately familiar with it and not introducing some hybrid monster which screws those people off. Just my two cents. Sorry.
2015 UPDATE: Multi-line string literals were introduced in Visual Basic 14 (in Visual Studio 2015). The above example can be now written as:
Dim s As String = "Hello World & Space" MSDN article isn't updated yet (as of 2015-08-01), so check some answers below for details.
Details are added to the Roslyn New-Language-Features-in-VB-14 Github repository.
Can a language have "add-ons" where you can add your custom parser logic? I think I never read of something like that, may be a new idea (not sure if good or bad).
FWIW, I would love to see support for heredocs and string interpolation. Those two features usually improves the readability of the source code.
I don’t agree with using C style formatting. That violates the principle of having only one way of doing things. The string interpolation feature would still do the job without making it too different from BASIC.
For the slicing I have never used this feature. We already can cast a string into a byte array. I probably would hold off to see a demonstrable need for the feature that is easy to read and understand.
So in the end, I only want the heredoc and string interpolation.
If there's some extensions on "normal Types" (later!) - then I'd prefer to use them with the (I think already agreed upon) "dot-notation" as (for example):
Same for SafeArrays:
As for "square bracketing" - I'd reserve that for a future "direct access on the String-allocation itself" - (avoiding the current fumbling with SafeArray-Mappings of a String to a 16Bit-IntegerType-Array):
That would be a usage of square-brackets, which would allow "convenient and fast implementations" (in all kind of scenarios, where such direct access provides a huge performance-boost, like e.g. Parsers or HashTable-implementations, whatever...)
Just my $0.02...
Olaf
Just create a Library which implements the primitive types as objects. Similar to https://bitbucket.org/hwoarang84/vbtypes/wiki/Home but without the jiggery pokery behind the scenes. The overhead of creating objects should be much smaller with twinbasic.
I like the Python multi-line string syntax:
s = """
This is a
multi-line string
"""
If we use backticks for string interpolation (as @WaynePhillipsEA mentioned in another issue), then we could reuse the backticks for multi-line string interpolation:
s = ```
Dear {Recipient},
{Body}
Sincerely,
{Sender}
@mwolfe02 When I see three quotes in a row it says to me that the string contains escaped quotes. That is the current VB behavior so we need to be careful not to confuse syntax here.
In discussion #261 user @mansellan said:
Personally, I prefer
$
- it's more canonical to BASIC:* In VBx, it's used as a string hint, * In VB.Net (and C#), it's used as an interpolation directive. * In other BASICs it's the only identifier of a string.
It has history.
Backticks have never signified anything special in any BASIC dialog I can think of.
This is the example given in 4. of the OP in this thread. I think that moving towards VB.NET makes the most sense for this project. We can take the best parts of VB.NET and avoid the pitfalls making twinBASIC superior to all other BASICs.
With interpolation, the need for c-style escaping is reduced, i.e:
$"Hello{vbNewLine}World"
(syntax TBD)
c-style escaping keeps keyboard and wrist healthy
In my first issue post, I did not mention that python can use both single quotes and double quotes to make string, which is truly convenient during writing code to deal with strings/text. Why I did not mention that? Because this may let some nostalgic BASIC users uncomfortable. But to my mind,
I like the Python multi-line string syntax:
s = """ This is a multi-line string """
What About just one double quote at the first line and at the end?
s = "
This is a
multi-line string
"
c-style escaping keeps keyboard and wrist healthy
In my first issue post, I did not mention that python can use both single quotes and double quotes to make string, which is truly convenient during writing code to deal with strings/text. Why I did not mention that? Because this may let some nostalgic BASIC users uncomfortable. But to my mind,
1. computer languages always evolve in some ways, one of which is to make user type/read code easily maybe via inventing some syntax or borrowing syntax from other languages. 2. true nostalgic user should use QBasic for DOS, instead of VB/twinbasic/and any other modern BASIC implementations
The problem that I see is that single quotes in VB mean starting a comment.
As a starter for 10, I've uploaded a package containing the A CSharpish String.Format formatting helper code by Mathieu Guindon (aka RetailCoder).
My thanks to @WaynePhillipsEA in helping resolve some idiosyncrasies*.
*Absolutely and most definitely not crashes......
currently, the BASIC's code dealing with string is tedious and hard to read. So what about some extended features to relieve the user
support C-style escaped string, so that we can write and read code easily
instead of
of cause, a new type of string should be introduced, for exampleOperator ! (Escaped String Literal) in freebasic
string slice so we can write
instead of
this feature will save a lot of keyboard-typing and make the code shorter, especially a lot of LEFT/MID/RIGHT functions are need.
Further more, advanced operation can be performed easily, for example, a stride of 3 is used to get
ph
which is not easy to be done in BASICmulti-line string
string interpolation
Dim sql As String = $" SELECT {primaryKey}, Description FROM {inventoryTable} ORDER BY DateAdded "