twinBASIC Update: June 6, 2021
Highlights include Mid statement support, DefType support, multiple bug fixes, and a (sort of) announcement regarding unit testing support.
On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference. I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025. With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.
Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project. If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.
Highlights
It was a busy week for bug fixes. There were 13 new version releases (see Changelog below). There were 22 issues closed on the GitHub project page.
Mid statement support
In addition to the familiar Mid string function, the VBA language itself has a Mid statement. Though less commonly used, the Mid statement can be used to boost string handling performance in certain situations. Support for this feature was added to twinBASIC in version 0.10.717.
DefType statement support
You can use DefType statements to automatically assign a data type to newly declared variables based on the first letter of the variable name. From the docs:
Used at the module level to set the default data type for variables, arguments passed to procedures, and the return type for Function and Property Get procedures whose names start with the specified characters.
So, yes, you can use DefType statements. That said, do not use DefType statements in new code. They are an abomination in 2021. Instead, explicitly declare the data type of each variable, even if that data type is Variant.
As of version 0.10.800, though, any legacy code that uses DefTypes will now compile and run correctly in twinBASIC.
Various bug fixes
Most of the other new releases were bug fixes of various edge cases. I've been monitoring the discussion at the GitHub project page and I've been impressed with how quickly Wayne is resolving many of the reported bugs. For many bugs, the issue is opened and closed within 24 hours.
Around the Web
As the edge cases get edgier, the number of automated tests within the twinBASIC project will continue to rise. Writing the tests themselves will begin cutting further and further into development time. With this in mind, Cristian Buse suggested that Wayne might consider opening up the test writing chore directly to the community:
@WaynePhillipsEA Would it be worth to open up the testing to the community via another repository? So that more is covered with less of your time.
Wayne responded that he was open to the idea, but he wants to wait until he can support unit testing directly within twinBASIC. Unit testing support is on hold, as Visual Studio Code itself is set to release a new testing API. Wayne will then leverage VS Code's testing features for twinBASIC's own unit testing implementation.
@cristianbuse yes, I think so. I would like to see #54 implemented first, so we can start in a formal and structured manner. I believe the necessary testing features in VS code are due to land in a few days.
To Wayne's point, the relevant VS Code Testing API issue is listed under the June 2021 Milestone for the Visual Studio Code project.
Here's to hoping unit testing makes an appearance in twinBASIC sometime later this year.
Changelog
Here are the updates from the past week. You can also find this information by installing the twinBASIC VS Code extension and clicking on the Changelog tab of the extension page:
[v0.10.1088, 6th June 2021]
- fixed: VBA.Collection handling of keys with vbNullstring, strings with embedded vbNullChars, and strings containing uneven BYTE data [ https://github.com/WaynePhillipsEA/twinbasic/issues/191 ]
[v0.10.1076, 5th June 2021]
- fixed: nested UDT accessors in a with-block were not being handled correctly, resulting in bad codegen [ mentioned in https://github.com/WaynePhillipsEA/twinbasic/issues/190 ]
[v0.10.1066, 5th June 2021]
- fixed: support the hack for obtaining the SAFEARRAY structure behind an array, via the Not Not method [ https://github.com/WaynePhillipsEA/twinbasic/issues/184 ]
- changed: KeyCodeConstants is now an enum rather than a module with constants, to match VB6 [ https://github.com/WaynePhillipsEA/twinbasic/issues/185 ]
- fixed: prevent use of internal Module types as a datatype [ https://github.com/WaynePhillipsEA/twinbasic/issues/185 ]
- changed: ColorConstants is now an enum rather than a module with constants, to match VB6
- changed: SystemColorConstants is now an enum rather than a module with constants, to match VB6
- fixed: ElseIf and Else can now have breakpoints set on them, and stepping through code steps on them [ https://github.com/WaynePhillipsEA/twinbasic/issues/181 ]
[v0.10.975, 4th June 2021]
- fixed: double-free of Variant in For-Each variant array iterator [ https://github.com/WaynePhillipsEA/twinbasic/issues/189 ]
[v0.10.959, 4th June 2021]
- fixed: more standard library issues relating to the ByRef-Variant changes introduced in 0.10.933 [ https://github.com/WaynePhillipsEA/twinbasic/issues/182 ]
[v0.10.951, 4th June 2021]
- fixed: VarType regression due to changes in VT_BYREF handling elsewhere in 0.10.933 release [ https://github.com/WaynePhillipsEA/twinbasic/issues/182 ]
- fixed: regression in handling of Mid statement vs Mid function [ https://github.com/WaynePhillipsEA/twinbasic/issues/147 ]
[v0.10.933, 4th June 2021]
- fixed: Array() in the standard library now returns an array holding copies of the input values, not references to them [ https://github.com/WaynePhillipsEA/twinbasic/issues/179 ]
- fixed: Abs() and Round() in the standard library were not handling VT_BYREF inputs properly [ https://github.com/WaynePhillipsEA/twinbasic/issues/180 ]
- fixed: ByRef handling in Variant-call runtime evaluation [ https://github.com/WaynePhillipsEA/twinbasic/issues/183, https://github.com/WaynePhillipsEA/twinbasic/issues/182 ]
[v0.10.871, 3rd June 2021]
- fixed: passing a UDT member array element to a ByRef parameter [ https://github.com/WaynePhillipsEA/twinbasic/issues/177 ]
- fixed: explicitly disallow array declerations and runtime ReDims to arrays with zero or negative elements [ https://github.com/WaynePhillipsEA/twinbasic/issues/176 ]
- fixed: explicitly disallow ByVal on UDT parameters
- fixed: explicitly disallow ByVal on Array parameters
- fixed: explicitly disallow changing of array datatypes at runtime when not in a variant container [ https://github.com/WaynePhillipsEA/twinbasic/issues/177 ]
[v0.10.833, 2nd June 2021]
- fixed: matching up of tB internal version of IUnknown with stdole.IUnknown in paramter matching [ https://github.com/WaynePhillipsEA/twinbasic/issues/164 ]
- fixed: VBA.Collection::Add when called late-bound from IDispatch [ https://github.com/WaynePhillipsEA/twinbasic/issues/158 ]
- fixed: corrected some internal attributes on VBA.Collection interface [ https://github.com/WaynePhillipsEA/twinbasic/issues/153 ]
[v0.10.810, 1st June 2021]
- fixed: DAP regression where enum values in the debugger locals window could cause a DAP fault [ https://github.com/WaynePhillipsEA/twinbasic/issues/174 ]
- fixed: duplicate implementations of same member now explicitly disallowed [ https://github.com/WaynePhillipsEA/twinbasic/issues/172 ]
[v0.10.800, 1st June 2021]
- added: support for legacy DefType statements (DefBool/DefByte/DefInt/DefLng/DefLngLng/DefLngPtr/DefSng/DefDbl/DefDate/DefCur/DefDec/DefStr/DefObj/DefVar) [ https://github.com/WaynePhillipsEA/twinbasic/issues/23 ]
[v0.10.717, 31st May 2021]
- added: support for Mid/Mid$ statement [ https://github.com/WaynePhillipsEA/twinbasic/issues/147 ]
- added: support for MidB/MidB$ statement
- fixed: with block expressions not allowing UDTs from parameters [ https://github.com/WaynePhillipsEA/twinbasic/issues/171 ]
- improved: explicitly disallow UDTs and enums with no members [ https://github.com/WaynePhillipsEA/twinbasic/issues/170 ]
[v0.10.660, 30th May 2021]
- fixed: added windowsVerbatimArguments option in the call to Node.js execFile from the VS code extension to avoid escaping of EXE arguments in the debug session [ https://github.com/WaynePhillipsEA/twinbasic/issues/169 ]