Replies: 11 comments 20 replies
-
Yes this seems useful, definitely in the realm of "Solving problems is the point" from the language design principles. At the expense of "Readable code is better than terse code" as dynamic string expressions cannot be debugged at design/compile time, "Fewer ways are better than many ways" ("There should be only one obvious way") - since it allows rewriting any normal code to now use late bound stringified syntax. For those reasons two ideas spring to mind:
|
Beta Was this translation helpful? Give feedback.
-
The Microsoft Access Application object includes an |
Beta Was this translation helpful? Give feedback.
-
@mike: Yes, perfectly right. The major drawback of this solution seems, that Access needs to be installed on the end user's pc. If that's not the case, Access Eval() won't run. Or does a workaround exist? The proposed native Eval() would alway work, regardless of external DLL's. This is especially true, if you want to support other operating systens (Linux etc.) . @Greedquest: Yes very good points. Eval() needs to be controlled, otherwise it's sort of Evil(). |
Beta Was this translation helpful? Give feedback.
-
As said a pcode interpreter would do the trick. But to get this really working you will need to implement a complete interpreter too. Would be the best soloution as well as the most complex ones. On the other hand, most things you need for a interpreter is alreday there i guess. GFA basic has had this function. Which indeed make it very powerful. Its also handy while testing code. A interpreter is way more error tolerant and you could change code during runtime as in vba. Which is really cool and time saving :). As a workaround you can currently pass a com object to VBS and maybe set some var to a callback function. (add the code you need interpreted as a string). This works fine already. With TABLACUS on github this will work also for 64 bit. But also true - not on linux. So the in the endgame Wayne will have finally provide some king of vb6 interpreter as well. Which is not the most worse things for the end users but for Wayne :) And if he is clever he made it in some way like it is with the script control where yo can choose between JS and VBS. So maybe some would be happy to call pyton or ruby code as well. But as also discussed. We can not yet clone Wayne :). So let the poor guy finalize the basic things first :). |
Beta Was this translation helpful? Give feedback.
-
In vbWatchdog, I already solved similar problems. There we have an VBx IDE addin that provides automatic line numbering (that can be exactly matched to line numbers deterministically gained from VBx p-code at runtime). One of the problem areas is that the IDE addin has to know which lines of code are 'live' and which are 'dead' due to conditional compilation. Note that the conditional compilation constant, and the If expression in the source code was evaluated in the addin in order for it to determine which line of code was live/dead which can be seen by the assigned line numbers to the left of the code. The vbWatchdog Addin does not do any complicated codegen... it just generates simple expression trees and evaluates everything by passing values to the OS provided Variant functions. Sure, this means everything gets treated as a Variant, so performance is not great. But it's simple, and it works well. Performance is never a big concern for Eval() anyway, given that you're parsing sourcecode from text in the first place. It will need some refinement, but re-using the expression evaluator from the vbWatchdog VBE Addin, I believe, is the best way forward for this. |
Beta Was this translation helpful? Give feedback.
-
@rexxitall: I expect, it will take 6-12 months for Wayne to sort out all relevant issues regarding "classic VB", so if there would an Eval() after this period, I'm fine. @wqweto: @wayne: |
Beta Was this translation helpful? Give feedback.
-
Just a note: I use the VBS soloution often in my projects since years. Also the 64 bit ones via TABLACUS. It is surprising fast. In one area i use even vbs as CGI on Apache (on localhost !). Sure you will not win every race with it. But it seems MS has speed up vbs during the years a lot - or intel :D A small trick is also to put the time consuming routines in a (COM) dll. So if you just use VBS or the VBS script object as "glue" you get already a lot out of it. Which also adress the problem to keep some application internals secret. Only problem is to debug vbs code. There are a few VBS editors out but as closed source. But if you has hands on VBA you can test it quite well if you put the new VBS routines temporary in a module. Best cheapest other soloution is to buy vbsedit. VS is also possible but this will always load a new instance of VS. Not really handy. |
Beta Was this translation helpful? Give feedback.
-
@rexxitall: @Greedquest: @wqweto: |
Beta Was this translation helpful? Give feedback.
-
OK, I'm lost. I'm a .Net developer, so I'll try to cope from there. .Net has had assembly metadata since v1. It supported reflection, by storing the shape of all code alongside the bytecode. Anything could be instantiated or called by accessing that metadata. You could even emit assemblies dynamically, by directly writing IL. Recently, the Roslyn compiler has also made it possible to compile source code at runtime. IIUC, you have to incur significant cost to do so. Most recently, source generators allow you to emit code at compile-time (with some restrictions), and avoid the runtime cost. TwinBasic compiles to native. It doesn't have metadata to support reflection. And it doesn't have the option to do on-the-fly compilation. Feel like I'm missing something here. |
Beta Was this translation helpful? Give feedback.
-
At first, thanks to all participants for their high level input. There's a reason, why dynamic languages like Python are immensely popular: they solve today's programming challenges like AI in a fitting dynamic manner. VB is the perfect product for "classic" programming themes like business software with a certain restricted market appeal. I think TB, as VBs I'd like to clarify, what Eval() means in my proposal. If you have a source code line like Call Func1(Parm1) we define that Func1 will start at address 1000, Parm1 will be at address 2000. Compiler/Linker know both adresses and are satisfied. I actually need a way in TB to formulate something like Call *Adress(*Parm1) meaning, I want to dynamically call known functions adresses with known parm adresses (classical pointers), but in a more user friendly way like defined above. I would be satisfied with an Access Eval(), only native in TB. No need to generate whole new programs, which would have to be compiled on the fly. That's unsolvable, endless recursive generation could happen (generated programs generate new programs and so on). Maybe Wayne could give a a hint, what his proposed solution would be be capable of? |
Beta Was this translation helpful? Give feedback.
-
Hmm... perhaps what we'd really need here, then are multiple EVAL() gateways. An architecture like that would bring in the flexibility for those future AI-driven needs without burdening tB native-compiled .exe projects with the needed runtime support systems as a whole. They only get "hung on" only when needed. So think, less of "an Eval() function" and more of designing an add-on interpretative ecosystem to work in harmony with tB. |
Beta Was this translation helpful? Give feedback.
-
VBS, Python and other languages can dynamically call a function via "Eval". The combination of this proposed
native "Eval" and VB control arrays would open the field for TB as a truely exceptional language, mixing compilation and dynamic interpretation.
Example:
func = "res = Call AnswerToLife(42)"
Eval(func) ' TB now calls Function AnswerToLife with value 42, pulling result into res
Debug.Print res ' Hopefully true according to hitchhiker's guide ;-)
Yes, this could get complicated, but I think it would be worth the effort.
Beta Was this translation helpful? Give feedback.
All reactions