tag:blogger.com,1999:blog-2428374771421713311.post7056615984323266437..comments2024-03-10T12:04:17.661-07:00Comments on The Oracle at Delphi: A look at "array of const" for fun and profitAnonymoushttp://www.blogger.com/profile/10119008505905401707noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-2428374771421713311.post-51898497325774920472007-06-02T21:30:44.000-07:002007-06-02T21:30:44.000-07:00> which has some interesting implications for &...> which has some interesting implications for <br><br>> 64bit<br><br><br>Hm, I hope this means what I hope it means ;)Michael Elsdorferhttp://www.elsdoerfer.infonoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-46516977408356370582007-06-03T17:38:01.000-07:002007-06-03T17:38:01.000-07:00The one additional step that the compiler needs no...The one additional step that the compiler needs now is something akin to the C# params keyword. The square brackets are only there because the compiler requires them at present - internal implementation need not be affected. Oh, and by the way, I use this functionality a lot and it has saved me from lots of repetitive code - nice going.Cobus Krugernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-71531403182062432452007-06-03T19:31:55.000-07:002007-06-03T19:31:55.000-07:00Your blog makes me laugh. Every day with BDS 2006,...Your blog makes me laugh. Every day with BDS 2006, i have tens of access violations, and lot of exotic errors. Imagine, I made a windows script which kills the BDS process. And what are you doing at <a title="" href="http://www.codegear.com" rel="nofollow">CodeGear</a> ? Blogs & chatting. Web. Oh, what a shame, your web site is not Web 2.0... But i am sure you are working hard on it. It is so funny.arthurnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-14594855814997234782007-06-12T20:00:31.000-07:002007-06-12T20:00:31.000-07:00Java 5 added something similar with their new stat...Java 5 added something similar with their new static class function format() of the String class. Made possible with their new varargs in Java 5.<br><br><br>Basically, it brings printf like formatting to Strings in Java.Jeff Carbellohttp://www.dvdorganizer.com/delphinoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-61449908712961909502007-06-06T10:11:33.000-07:002007-06-06T10:11:33.000-07:00That case statement reminded me of this quote:&quo...That case statement reminded me of this quote:<br><br><br>"Im not against types, but I dont know of any type systems that arent a complete pain, so I still like dynamic typing." - Alan Kay in The Meaning of Object-oriented Programming<br><br><br>I find myself using dynamically-typed languages more and more frequently.blakenoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-66163633194141779492007-06-02T08:33:50.000-07:002007-06-02T08:33:50.000-07:00This is one of the things that sold me on Delphi w...This is one of the things that sold me on Delphi way back in 1994. I remember seeing a short example in Jeff Duntemann's PC Techniques (or was it Visual Developmer Magazine by then?) and being incredibly annoyed that the short accompanying article didn't explain what the square brackets were doing there and how this trick worked! But another article in the same or the next issue cleared it up, and after that it was just a matter of time until I managed to convince someone at Borland Australia that they did, in fact, have a product named Delphi and that they should sell one to me as soon as it was in stock.Eric TF Batnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-84860870220062777222007-06-02T15:02:08.000-07:002007-06-02T15:02:08.000-07:00I built a version of sscanf that uses this functio...I built a version of sscanf that uses this functionality. Unfortunately, you can't make the arguments function like a Var, so unfortunately, everything is passed as a pointer, EXCEPT longstrings (shortstrings are passed as a pointer).<br><br><br>ie: sscanf(inputstring,'%d %d %s',[@i,@j,s]);<br><br><br>Needless to say, typesafety is out the window, except for the strings.<br><br><br>It would be nice if a future revision could handle that (everything is a pointer to data, but you still get the type), but I doubt you would extend the functionality for just one person's function (ah well...)<br><br><br>I should probably put the code back up on my website one of these days. Maybe once I finish rewriting it to improve the parser's performance. Anyone still interested in sscanf functionality or has everyone learned to live without it?C Johnsonnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-23754299023608171042007-06-02T15:06:32.000-07:002007-06-02T15:06:32.000-07:00Oh, that reminds me.The format functionality needs...Oh, that reminds me.<br><br><br>The format functionality needs to be better integrated into the VCL.. I'm forever creating object descendants that only really add functionality that adds formatted strings where strings are allowed..<br><br><br>ie: I typically overload TStringList's .Add functionality to include:<br><br><br>Function TMyStringList.Add(FormatStr : String; Const Args : Array Of Const);<br><br><br>Begin<br><br> Add(Format(FormatStr,Args));<br><br>End;<br><br><br>and all the rest of the .add features. I wish it was part of the TStrings definition - this sort of thing saves a LOT of typing later.<br><br><br>Actually, there are a LOT of places the VCL would benefit from this type of overloading (including ShowMessageFmt, which should just overloaded into ShowMessage with ShowMessageFmt deprecated, as it was added before overloading as I recall..)<br><br><br>Just my 2 cents.C Johnsonnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-40143502252750148542007-06-03T01:54:42.000-07:002007-06-03T01:54:42.000-07:00We have a TDialogForm class which is responsible t...We have a TDialogForm class which is responsible to do a Windows Readln on steroids (think about at something similar to Tcl/Tk).<br><br><br>Something like<br><br><br>TDialogForm = class(TCustomForm)<br><br>...<br><br>public<br><br> procedure AddLabel(aCaption: string; aLineReductionPercent: integer=20);<br><br> procedure AddEdit(var aTextVal: string); overload;<br><br> procedure AddEdit(aCaption: string; var aTextVal: string); overload;<br><br> procedure AddDDList(aCommaTextVal: string; var aItemIndex: integer; aAutoSize: boolean=True); overload;<br><br> procedure AddDDList(aCaption, aCommaTextVal: string; var aItemIndex: integer; aAutoSize: boolean=True); overload;<br><br> procedure AddCheckBox(aCaption: string; var aChecked: boolean);<br><br> procedure AddButton(aCaption: string; aResult: TModalResult; aNewLine: boolean=False; aAutoSize: boolean=False; aDefault: boolean=False);<br><br> procedure AddSeparator(aSpaceOnly: boolean=False);<br><br> procedure AddDatePicker(var aDate: TDateTime); overload;<br><br> procedure AddDatePicker(aCaption: string; var aDate: TDateTime); overload;<br><br> procedure AddTimePicker(var aTime: TDateTime);<br><br> procedure AddTrackBar(aMin, aMax: integer; var aPosition: integer); overload;<br><br> procedure AddTrackBar(aCaption: string; aMin, aMax: integer; var aPosition: integer); overload;<br><br> procedure AddMemo(var aText: string); overload;<br><br> procedure AddMemo(aCaption: string; var aText: string); overload;<br><br> procedure AddRadioGroup(aCaption: string; aCommaTextVal: string; var aItemIndex: integer);<br><br> procedure AddList(aCommaTextVal: string; var aItemIndex: integer);<br><br> procedure AddCrLf;<br><br>...<br><br> function Execute(aCaption: string; Buttons: TMsgDlgButtons; aAccept: TModalResult=mrOk; aDefault: TMsgDlgBtn=mbHelp): TModalResult; <br><br><br>which pushes the values from the UI controls which are dynamically generated, layed out, and filled based on 'Add' procedures from above. A more general approach, based on variants like:<br><br>DlgRead(aCaption: string; aValue: array of const); <br><br>DlgReadLn(aCaption: string; aValue: array of const);<br><br><br>...in which the class will be responsible by choosing the right input controls to read the values will be, imho, a wellcome addition to Delphi.<br><br><br>hth.m. Th.noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-7729700468593425032007-06-03T05:54:01.000-07:002007-06-03T05:54:01.000-07:00As it happens I posted about how array of const co...As it happens I posted about how array of const could be used by user code back in the <a href"http://groups.google.com/group/comp.lang.pascal/browse_thread/thread/d86f368e885c98e0/164e0ba6c7051d35">last millennium</a> ;) - it was undocumented at the time. <br><br><br>"Actually, if you really want the gory details"<br><br><br>Heh - thanks for the link and vote of confidence, Allen!<br><br><br>We'll see - maybe I'll pick you up on this and write something about calling conventions and order of parameter passing in the future.<br><br><br>"Another side benefit of this is that you can now refer to the position of an element "<br><br><br>Incidentally, this feature is available in C-style xprintf functions, too (and is a well-known source of security holes).<br><br>Hallvard Vassbotnhttp://hallvards.blogspot.com/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-80745823417061759582007-06-04T03:22:01.000-07:002007-06-04T03:22:01.000-07:00Arthur -> D2007 is significantly more stable, b...Arthur -> D2007 is significantly more stable, but some problems can be caused by components.<br><br><br>Which isn't to say the D2007 IDE is perfect. <br><br><br>Mine has learned a new phrase : "catastrophic failure".<br><br><br>Since I've gone a month without ever seeing it, I gotta wonder what sundenly drove it insane (aside from being coded to run in an infinite loop when it happens to the structure view...)<br><br><br>When the compiler has a catastrophic failure, it at least just turns of the compile functionality and makes you restart the IDE (unlike the structure view... ugh)..<br><br><br>Annoyingly, it will probably vanish without me ever pinning down what upsets it so.C Johnsonnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-35432398325221081612007-06-05T01:43:29.000-07:002007-06-05T01:43:29.000-07:00"it will automatically pick the most natural ..."it will automatically pick the most natural type to use"<br><br><br>These natural choice behaviour was changed since Delphi 5. So beware if you upgrade your code to a new version of Delphi.<br><br><br>An integer with value 10 stored in a variant was always of type vtInteger, but Delphi 2006 converts it to a vtSmallInt, resulting in a lot of:<br><br>"else Writeln('Unsupported');"<br><br><br>Btw, it is good to see the team blogging.<br><br><br>Best regards,<br><br>BasBas Groothttp://teach2000.memtrain.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-81325003729196761382007-07-09T20:24:06.000-07:002007-07-09T20:24:06.000-07:00m. Th.What a difficult post to read. I had to real...m. Th.<br><br><br>What a difficult post to read. I had to really struggle intellectually. If this is the standard of communication between the developers in the Delphi group - then that explains a lot.<br><br><br>I think it's a cop-out to ask customers to upgrade because they are having problems with the software you sold them. It's probably morally wrong and also, perhaps could be said that Delphi is not 'fit-for-purpose'. Yes, of course, building an IDE is going to be a complicatedJohnnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-36196608089193268052007-07-09T20:25:44.000-07:002007-07-09T20:25:44.000-07:00What happened to the rest of my post?Well, I'm...What happened to the rest of my post?<br><br><br>Well, I'm not going to type it twice.Johnnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-61122186689315970942010-01-23T14:35:37.000-08:002010-01-23T14:35:37.000-08:00Mr. Watson, Did that make you feel better to impug...Mr. Watson,<br><br> Did that make you feel better to impugn my intelligence and competence by ridiculing a simple spelling mistake? Starting off a comment with insult and ridicule is a sure way to be completely ignored...Allen Bauerhttp://blogs.codegear.com/abauer/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-25448283658533813362009-08-14T22:00:02.000-07:002009-08-14T22:00:02.000-07:00I noticed that you use VWideChar for the vtWideStr...I noticed that you use VWideChar for the vtWideString case. Shouldn't that be VWideString?Simon Armstrongnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-35679888101375702402010-01-22T08:02:41.000-08:002010-01-22T08:02:41.000-08:00A very interesting article which helped me underst...A very interesting article which helped me understand open arrays. However, you write "and definately (sic) do try this at home". Can you not afford a spellcheck program? Did you miss / forget your elementary education? Didn't your job description include something like "excellent communication skills, both written and verbal" as a criterion?<br><br>It might be worth clarifying your assertion "If you also look closely, all the data fields are the same size" by pointing out the reason it is:<br> TVarRec = record { do not pack this record; it is compiler-generated }<br> case Byte of<br> vtInteger: (VInteger: Integer; VType: Byte);<br> vtBoolean: (VBoolean: Boolean);<br><br>and not:<br><br> TVarRec = record { do not pack this record; it is compiler-generated }<br> VType: Byte;<br> case Byte of<br> vtInteger: (VInteger: Integer);<br> vtBoolean: (VBoolean: Boolean);<br><br>is to preserve the ability to typecast. Putting the byte at the front wouldn't affect speed due to alignment because the record isn't packed.Elementary Watsonnoreply@blogger.com