-
Content Count
407 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Kryvich
-
@Zacherl If a runtime exception occurs it means that you forgot to put an assertion somewhere. :) OK madExcept is a great tool, as well as 100% test coverage is very desirable. I just want to say that exceptions are probably the easiest and least time-consuming way to deal with bugs. Another point is the use of custom enumerated types instead of general types Integer, Byte, Char etc. We, Delphi programmers, love strong typing. (And do not love the Variant type :) ).
-
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
@Jacek Laskowski To improve clarity it is better to use enumerated types instead of generic types such as Boolean, Byte, Integer. // In library: type TOwnsObjects = (No, Yes); // User code: fRecipients := TCollections.CreateList<TRecipient>(TOwnsObjects.Yes); This will require changes in a framework code, but will not require complicating a syntax of the language. -
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
@dados The right side of assignment can be any statement of a type that has members. Of course it can be the function call that returns an object or a record as well. This extended with statement should prompt the compiler to create a temporary readonly variable cr, without increasing the count of references, for optimization purposes. Note: it's just my suggestion how to make a with statement more convenient and useful for a programmer and Delphi compiler. I am not participating in Delphi Beta testing, and I don’t know if they made any changes to this statement. -
The best way to fix a bug is to identify it as early as possible. I use asserts to validate the input parameters of subroutines, to verify the result of a function, and sometimes inside a subroutine if needed. Asserts always enabled during development, at alpha and beta testing stages. After release, they can be disabled if they noticeably affect the speed of the application.
-
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
Or even better to enchance the with statement as follows: with const cr := ControlRange as IHTMLControlRange do begin cr.select; cr.execCommand('Cut', False, EmptyParam) { do not localize } end; "const cr" because inside the statement cr is used only to access its members. -
firemonkey Compiler Defines for FireMonkey and VCL in inc files.
Kryvich replied to Ugochukwu Mmaduekwe's topic in General Help
Yes, I was going to suggest to create frameworksetting.inc in your application source folder with a suitable define (FMX or VCL). And then {$include frameworksetting.inc} to every unit of your library. Then you don’t have to manually modify UserTools.proj on every developer's machine. -
firemonkey Compiler Defines for FireMonkey and VCL in inc files.
Kryvich replied to Ugochukwu Mmaduekwe's topic in General Help
_ -
firemonkey Compiler Defines for FireMonkey and VCL in inc files.
Kryvich replied to Ugochukwu Mmaduekwe's topic in General Help
@Ugochukwu Mmaduekwe Try to put {$INCLUDE MY.INC} after uses clause with VCL or FMX files. The FireMonkeyVersion constant should be declared before you check it in your INC file. -
firemonkey Compiler Defines for FireMonkey and VCL in inc files.
Kryvich replied to Ugochukwu Mmaduekwe's topic in General Help
Form the Delphi help, "IF directive": This code works fine for me: procedure TForm1.Button1Click(Sender: TObject); begin {$IF DECLARED(FireMonkeyVersion)} ShowMessage('Here is FireMonkey!'); {$ELSE} ShowMessage('Perhaps it''s VCL'); {$IFEND} end; -
Warning W1010: Method hides virtual method of base type
Kryvich replied to Kryvich's topic in RTL and Delphi Object Pascal
Ouch! Thank you. :) P.S. I encountered this situation in GOLD Parser Engine 5 that I've converted from Lazarus. Now this project compiles without any warnings, I'm happy! -
Does anyone have some library/unit to make coding of tokeniser/parser/somekind of tree easier?
Kryvich replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
@pyscripter Thank you for the finds! I had some free time, so I adapted Teo's parser for Delphi. Also corrected some bugs in this parser and in the grammar for the Delphi 7.0 language. https://github.com/Kryuski/GOLD-Parsing-System-For-Delphi @Markus Kinzler Interesting. I will definitely follow this project. Update: Parse::Easy is written using Perl. Yes, it can generate a lexer and a parser in Delphi laguage, but hey! I do not want to install another IDE and learn a new language when such things may well be written in Delphi. Once they wrote ErrorInsight on J#, and I think it was a bad decision. Maybe later, I or someone else can rewrite Parse::Easy to Delphi. But now it does not make sense, since it is still in the beta stage. -
Does anyone have some library/unit to make coding of tokeniser/parser/somekind of tree easier?
Kryvich replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
@Uwe Raabe I read a little about this parser, great tool! There is a ready-to-use grammar for Delphi, though without the support of new language features, such as generics, anonymous functions and closures. And there is several GOLD Parser Engines with sources written in Delphi. I took the most recent version and updated it a bit, now it can be compiled in Delphi 10.2.3. Put it on GitHub. -
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
I found another case where inline variables will be useful - as substitution for a with statement. Yes I know: nowadays no one use them... (Just kidding, I found with statements even in the Delphi 10.2.3 source folder). with ControlRange as IHTMLControlRange do begin select; execCommand('Cut', False, EmptyParam) { do not localize } end; After 10.3 it can be replaced with begin var cr := ControlRange as IHTMLControlRange; cr.select; cr.execCommand('Cut', False, EmptyParam) { do not localize } end; So the with statement can be finally deprecated and excluded from the language. Or maybe we will can write: with var cr := ControlRange as IHTMLControlRange do begin cr.select; cr.execCommand('Cut', False, EmptyParam) { do not localize } end; -
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
Can't wait for the new release. How about complex structures, is it possible? // Before Delphi 10.3 function TestInlineArray: string; var strArray: array of string; begin strArray := ['Delphi', 'JavaScript', 'Python', 'PHP', 'C']; Result := strArray[Random(5)]; end; // Inlining function TestInlineArray2: string; begin var strArray := ['Delphi', 'JavaScript', 'Python', 'PHP', 'C']; Result := strArray[Random(5)]; end; Who can answer? Simple + or - would be OK. :) -
As a side note: ... mov [ebp-$04],eax mov eax,[ebp-$04] // <--- ??? call @UStrAddRef ... Compiler optimization is on. There is a place for optimizations. 😉
-
Not quite. Delphi does not increase the reference count for const parameters. Therefore, this variant will be faster. function x(const input: string; var output: string): boolean; push ebp mov ebp,esp add esp,-$10 mov [ebp-$08],edx mov [ebp-$04],eax ... function x(input: string; var output: string): boolean; ... same commands ... mov eax,[ebp-$04] call @UStrAddRef ...
-
function x(const input: string; var output: string): boolean; begin output := input; UniqueString(output); //... end; ?
-
BTW Delphi IDE has MultiPaste feature, which can paste lines adding a prefix and a suffix, and escaping quotes. https://www.youtube.com/watch?v=ca8itZ9xXnA (Don't know how to insert Youtube video).
-
@Dany Marmur Yes, I see LSP is based on JSON-RPC messaging. I was confused by plugins written in TypeScript.
-
Documentation says that FireMonkey provide a great deal of customizations without subclassing. I found this: Prepare PNG for ActiveLink and SourceLink backgrounds. Right click on the edit. Edit customs style... Select EditStyle.Background Double click ActiveLink Add your PNG image. Adjust positions for SourceLink and ActiveLink. How to make it easier and more correct - you decide. P.S. FMX is multiplatform so you may have to make a style for each platform for which the program is intended.
-
I think 5 function calls or 5 assigments is not the best code style. Consider these variants: SQL.Add('SELECT EntCity, EntStageName' + sLineBreak + 'FROM Entertainers' + sLineBreak + 'WHERE 1=1' + sLineBreak + 'AND TEST=''TEST''' + sLineBreak + 'ORDER BY EntCity ASC, EntStageName ASC'); CommandText := 'SELECT EntCity, EntStageName' + sLineBreak + 'FROM Entertainers' + sLineBreak + 'WHERE 1=1' + sLineBreak + 'AND TEST=''TEST''' + sLineBreak + 'ORDER BY EntCity ASC, EntStageName ASC'; Optionally replace line breaks with spaces: SQL.Add('SELECT EntCity, EntStageName ' + 'FROM Entertainers ' + 'WHERE 1=1 ' + 'AND TEST=''TEST'' ' + 'ORDER BY EntCity ASC, EntStageName ASC');
-
Is it possible to write a language server in Delphi/Pascal, or should it be written in languages such as Java, JavaScript, TypeScript? BTW ErrorInsight was written in J# (correct me if I'm wrong), and it was a bad decision. Well I see the language server plugins for C/C++ written in C++, D plugin written in D, Dart Language Server written in Dart etc...
-
For me Delphi 10.2 IDE is stable and very resposive. I tried Oxygene in Visual Studio, it was noticeably slower on my computer.
-
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
I just noticed that these innovations will make the functional elements in Delphi code more compact and easy to understand. And if we talk about functional programming, please look at this article by Joel Spolsky ("Can Your Programming Language Do This?"). We can write code in the same style, and after 10.3 we will be able to remove unnecessary syntax elements, while maintaining strong typing of Delphi language. -
Inline Variables Coming in 10.3
Kryvich replied to Marco Cantu's topic in RTL and Delphi Object Pascal
OK, let's call it functional programming elements in an imperative language. In 10.3 and subsequent releases these elements will be even more.