UBBFriend: Email This Page to Someone!
uCalc Message Forums
Transitioning from UCalc Fast Math Parser 2.0 to the next version
|next newest topic | next oldest topic|
|Author||Topic: Transitioning from UCalc Fast Math Parser 2.0 to the next version|
posted 04-09-2007 04:18 PM
A. General comments
B. List of things that have changed
C. Features that are no longer supported
D. Partial list of new features
As work progresses towards the completion of the next version of UCalc Fast Math Parser, it is increasingly important for current version 2.0 users to start planning their migration towards the next version. Eventually, once the next version is released, regular support for 2.0 will likely come to an end, and be replaced with support for the new version.
This month's beta now includes specific support for UCalc Fast Math Parser in a separate download, for those who might not be interested in the advanced Language Builder functionality featured in previous betas this year. An effort was made to preserve compatibility between FMP 2.0 and this beta where possible. In many cases, however, it was not possible. It will be important to browse through the following lists (especially the list of obsolete features), and to also test the beta, in order to identify any changes that might prevent you from being able to do things you were able to do with FMP 2.0.
If you encounter any problem, now is the best time to speak up. Or if everything mostly works just fine, your feedback confirming this is equally requested. Your feedback may help accelerate the release of the next version.
Unfortunately, a help file is not yet available in this beta. However, demos files for VB.NET, VB classic, Delphi, C++ Builder, and PowerBASIC are included. Overall, you will likely understand how the beta works just by browsing through the demo source code.
Download the new UCalc FMP beta from www.ucalc.com/newbetafmp.html .
Everything mentioned below should be considered tentative, and is subject to further change.
- uCalc Fast Math Parser will likely no longer be the flagship product. The main item would be uCalc Language Builder, and uCalc FMP would simply be one out of many possible components that could be derived from the language builder. uCalc FMP only uses a fraction of the functionality of the language builder.
- By default relational operators (>, <, ==, etc...) return a -1 for True instead of 1.
- Only three exported routines from the DLL are required: 1. uCalc() which encapsulates the entire functionality of uCalc FMP / Language Builder, 2. ucEvaluate(), which can be derived from uCalc() but is exported separately for efficiency, and 3. the ucStrReturn helper function, which simply allows you to retrieve a string value from uCalc() (uCalc() itself can only return a 32-bit number).
In contrast, the DLL in version 2.0 exported dozens of routines. Functions such as ucDefineFunction, ucDefineVariable, etc..., are now merely wrappers that call uCalc(), and these are defined in the include file.
- Implementation across the various compilers is more uniform. Also, the PowerBASIC, Delphi, and C++ demos were updated to make them more user-friendly, just like the VB form-based demo. (A new VB.NET demo was added as well).
- Error Handling is very different.
Also, you have full control of the FPU, which can for instance, decide whether 1 / 0 should raise an error, or be treated as a numeric value of Infinity. The demo shows one of the ways to control the FPU.
Something important to all users, even if you don't care anything about FPU control per se, is that uCalc maintains a separate FPU word from your host program, and both are insulated from each other. The end result is that this resolves a problem that some users encountered, which was caused by their host program changing the FPU setting (without the programmer being aware), and preventing UCalc from working.
- Division-by-0, at least, was handled in version 2.0, even if in a limited way. Overflow, however, wasn't detected at all in 2.0. Now overflow too, and others are handled the same flexible way based on the FPU setting.
- Error numbers returned by ucError, and error messages returned by ucErrorMessage have changed. See the include file for new values and messages.
- ucErrorMessage was renamed to ucGetErrorMessage. The include file for PowerBASIC had a different syntax for ucErrorMessage. It is now uniform with other include files, and there is no separate ucErrMsg function.
- When you re-define a variable, it does not replace or change the old variable definition. Instead the old definition continues to co-exist with the new. The most recent definition will be the only one visible for subsequent use. But if you release the newer definition, the older definition will regain its place as the visible one.
- When you re-define a function, if it has the same arguments as the previous definition, then it behaves the same way as described in the previous paragraph for variables. If the arguments are different, then they operate as overloaded definitions, meaning that the appropriate definition will be used depending on the context. For instance, if you define MyFunc(x), and MyFunc(x, y), then you can use an expression such as "MyFunc(5) + MyFunc(3, 4)"
- Operator definitions.
- Alphanumeric names by default can no longer have a period (.) in them. It isn't hard-coded that way, however. You can change what constitutes a valid "alphanumeric" name by doing a search for "alphanumeric" in the include file, and modifying the regular expression pattern you find there.
- ucDefineVariable no longer supports an optional second string parameter. The optional second parameter is now for passing a thread handle.
- In addition to ucDefineFunction, ucDefineVariable, other functions as well, such as ucParse, etc... now have an optional last parameter for passing a thread handle.
- ucReset was removed and some of its functionality replaced. ucReset was a multipurpose routine. So each aspect will be discussed separately:
- ucDefineFunction and ucDefineVariable were preserved for compatibility. However, these are merely wrappers to the more flexible ucDefine function, which in turn places a call to the all-purpose uCalc() function. Advanced users might eventually want to use ucDefine directly for additional functionality.
- Strings are handled very differently.
- You are no longer restricted to defining your callbacks using a special uCalc kind of template (which consisted of a function with no args, which was required to return a floating point, even if you were dealing with strings). You will need to modify all your callbacks, first so that your code will work, and secondly to take advantage of the simpler way of creating callbacks.
- Some of the contact info found in the help file is outdated. The preferred contact information can be found at www.ucalc.com/contact.html
- Some user-level functions or operators are defined with several alternative names in version 2.0. For instance, both Fact() and ! for factorial. The following alternative names are no longer included: Fact, **, DIV, =<, =>, =, & (for AND), & (for CONCATENATE)|, ATN, LN, SQRT. You can easily re-instate any of these if needed.
- The following functions, operators, or constant(s) aren't present in this beta. They may or may not be included in the final: % (percentage), XOR, EQV, IMP, MIN, MAX, ASIN, ACOS, SEC, CSC, COT, Hyperbolic functions (SINH, COSH, TANH, etc...), EXP2, EXP10, LOG2, LOG10, RND, INT, SGN, CONCATENATE, PI. The programmer can define some of these on his/her own if needed.
- There are in fact no longer any "built-in" functions, operators, or constants at all. Some common items, such as arithmetic, trigonometric, and miscellaneous items are included in a library in the DLL, and are activated in the include file. You can remove, rename, or add items to the list. You can implement new items using the same kind of NativeCall procedure callbacks as the ones in the library, achieving the same maximum speed. (Standard procedures, which are easier to implement, can be defined as well, and are generally sufficiently fast).
- ucAlias was removed. Its functionality can be duplicated (and greatly superceded) with ucDefineSyntax. For the renaming aspect of ucAlias, see the RenameItem function defined in the Library.uc file that comes with the Language Builder (downloadable from www.ucalc.com/newbeta.html ).
- Implicit multiplication notation is no longer supported.
- Numeric base notations, such as #b101 (binary) or #hAEFF are no longer built-in.
- ucErrorData, along with ucGetErrorData and ucErrorData were removed. Use ucGetSymbol in place of ucGetErrorData.
- ucReset was removed. See earlier explanation.
- ucTrigMode, ucSetTrigMode, ucGetTrigMode. There is no direct replacement. However, there might be several potential strategies you can try, to mimic this.
- ucIsString was removed. Use uCalc(uc_GetItemData, ...) instead. You can now determine the data type (not just whether or not if it's a string), as well as other properties of an item. See ExprType in the Library.uc file of the Language Builder for an example of how to determine the data type of an expression.
- ucParam, ucParamStr, and ucGetParamStr were removed. Version 2.0 required you to define your callbacks in a special UCalc way. Retrieving arguments required the use of ucParam or ucParamStr. Now you don't have to pattern your callback in a special way for it to work with uCalc. With the new way of doing it, ucParam and ucParamStr are irrelevant. Callbacks are much easier to write (in fact you can call DLL functions that weren't even designed with uCalc in mind), and they will run faster as well.
- ucSetParamStr, and ucParamStr functionality in the context of ucPreParse is no longer available, since pre-parsing itself is no longer available.
- ucParamCount was removed for the same reason described earlier under ucParam. However, for functions with a variable number of arguments, you can retrieve the number of passed arguments using [... not documented yet]
- ucPreParse is no longer supported. The main example in version 2.0 involved two alternatives of a function definition. Now you can directly define multiple version of a function without doing anything extra for it to work. For aspects of ucPreParse's functionality dealing with expressions, use ucDefineSyntax instead.
- ucVariableValue, ucGetVariableValue, ucSetVariableValue, ucVariableValueStr, ucGetVariableValueStr, ucSetVariableValueStr. These are now irrelevant under the new way of doing things, as you can now attach a uCalc variable directly to the address of a variable in your source code. This results in less code, which also runs faster. See the source code for the Plot or Sum examples in the demo program.
Unfortunately, for "managed" code which makes it difficult (or impossible) to work with fixed pointers, something akin to ucVariableValue is still required. A special routine named ucSetValueDbl is defined in the VB.NET include file. It simply places a call to uCalc() using uc_SetItemData and uc_Value as parameters. This can be extended to other fixed-memory data types the same way, if needed. ucSetValueDbl is much less efficient than attaching the variable to an address.
The improvements mentioned below are relevant mainly in the context of moving from version 2.0 to the next version. uCalc FMP barely scratches the surface of the Language Builder's functionality, which is not discussed in this file. (Download the separate Language Builder file from www.ucalc.com/newbeta.html
- The IIF() function evaluates either the True argument or the False argument, depending on the value of the Condition argument, but not both, unlike version 2.0 which always evaluated both.
- You can define callback functions similar to IIF() such that arguments passed ByExpr (as opposed to ByRef or ByVal) are not evaluated ahead of time. This was not possible in version 2.0.
- It is no longer necessary to set up definition space boundaries ahead of time. Memory is gradually allocated as needed. You won't need ucReset, and you won't have to worry about running out of definition space (assuming you don't intentionally, or inadvertently devise a way to consume all your gigs of memory). And there is no maximum number of arguments per function.
- FMP 2.0 only allowed you to define infix (binary) operators. Now you can also define prefix and postfix operators as well. See DemoDefs.Txt for examples.
- FMP 2.0 operator definitions didn't allow you to set individual precedence levels for each operator, as you can do now. See DemoDefs.Txt for examples.
- Case sensitivity can be turned on or off. (It's off by default).
- User-friendly form-based demos for PowerBASIC, Borland C++ Builder, and VB.NET are now included. (VB classic, and Delphi already had form-based demos). [VC++ not yet].
- Support [partial] for VB.NET [Problems with callbacks for now. Send feedback if you have suggestions].
- Speed. The new uCalc should be much faster, both in terms of parsing speed, and in evaluation speed. The difference in speed may range from barely noticeable to very dramatic, depending on what you are doing, and in some cases which compiler you are using. By default, compilers that have native support for 80-bit precision can benefit the most in numeric calculations. Compilers that support pointers can create callbacks that use uCalc's NativeCall for more efficiency.
Also you can attach a uCalc variable to the address of a variable defined in your source code. See the source code for the Plotting, and Sum examples in the demo files (excluding VB.NET).
[Unfortunately, "managed" code (VB.NET) suffers a great speed penalty especially where ucSetValueDbl must be used. For best speed, create callbacks in a DLL compiled with an unmanaged compiler, which you can then call from VB.NET].
- Specific data types are supported, instead of only generic numeric and string.
- There is no longer a problem with using ucEval or ucEvalStr in your callbacks.
- Function overloading is supported.
- Multi-threading. See ucNewThread().
- Function recursion is supported.
- FPU word of host program is preserved.
- More function definition flexibility is supported.
- [Complex numbers]
- uCalc() encapsulates all functionality. You can call it from your source code, or even at the end-user level (if you choose to make this available to the end-user).
Note: Purchasing a license for version 2.0 entitles you to a free upgrade when the next version comes out.
[This message has been edited by Daniel Corbier (edited 04-09-2007).]
All times are Eastern Time (US)
|next newest topic | next oldest topic|
Copyright © 2000-2007 by Daniel Corbier
Powered by: Ultimate Bulletin Board, Version 5.42a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.
Powered by: Ultimate Bulletin Board, Version 5.42a