Language Syntax extensions for Native Mode
Posted: 18 January 2008, 15:42 PM
From another thread:
1. Consider the following declarations:The last one is not allowed but nevertheless it doesn't do any harm either. There is also an inconsistency between the declarations of bill and jenny. Perhaps the following is better:
2. What about Consts? Why couldn't they be declared in an external source e.g.
3. The Dim keyword is not completely orthogonal with Public and Private and doesn't match Visual Basic (which is the grand-parent of ZBasic). For variables, the Dim keyword should be reintroduced and made optional only in the case needed for backwards compatibility e.g.
4. Looking at the Visual Basic syntax for variables, the attributes are placed before the access modifier. However I think their concept of attributes is different to the one in ZBasic. The concepts however could be combined by defining a single attribute (in VB terms) called UsageAttribute and written in VB syntax as follows:
5. Taking this whole thought just one step further, it might be better to not use the Declare syntax at all and instead use the concepts from something like the VB WebMethodAttribute and call it something like "ExternalAttribute" e.g.
I'm just thinking (and perhaps over-architecting) the language syntax so that it is easy to make future extensions.
I like a language syntax that is consistent. It makes it easy on both the parser in my PC and the one in my head. Exceptions mean confusion. There are 5 separate points in this append on language syntax, extensibility and consistency.dkinzer wrote:Currently, an alias can only be defined for an external procedure via the Declare statement. I'm not sure what value there would be in allowing an alias for a normal ZBasic procedure.mikep wrote:Can the alias feature be applied to regular ZBasic sub/functions or only those that are declared?
1. Consider the following declarations:
Code: Select all
Public foo as Long
Public bar as Integer Alias foo
Public Declare bar2 as Integer Alias foo2
Public Declare bar3 as Integer Alias "_foo3"
Public Sub fred()
Public Declare Sub bill()
Public Declare Sub jenny Alias "jennifer"()
Public Sub kate Alias katherine()
Code: Select all
Declare Public Sub jenny() Alias "jennifer"
Declare Public Function jenny() As Byte Alias "jennifer"
Code: Select all
Public Declare Const frequency
Public Declare Const frequency2 Alias "_CPU"
Code: Select all
Dim bar as Long
Public Dim bar2 as Integer Alias bar
Public Declare Dim bar3 as Integer Alias foo3
Public Declare Dim bar4 as Integer Alias "_foo4"
Code: Select all
<Usage(Used, Inline)> Public Declare Sub bill()
Code: Select all
<External("foo3")> Public Sub jenny()