2016 ...
januari februari (2) maart (3) april mei (7) juni (1) juli (1) augustus september (5) oktober (1) november (3) december (5)
just an idea: var in code for variables of limited scope
2016-02-03 16:18 var-limited-scope [permalink]
I've been reading around a lot about the new programming languages (Go, Rust, D, WebJavaECMACoffee6asm.ScriptX) and there's ofcourse this thing, but I still do most work for work and distraction in Delphi. So all of a sudden, in a large code block (I know, I know, one is supposed to keep their methods many and small) I thought of something like this:
all_kinds_of_important_code();
var
s:string;
begin
s:=MyObject1.GetSomeString();
ProcessString(s);
StoreStringForFutureReference(s,Now);
end;
more_code_that_makes_the_world_tick(); //perhaps even using 's' but the one declared way above...
In light of the asynchronous programming most languages get pushed upon them, and the need to have 'scope' outliving the usual runtime of the function call, this may have been considered. But purely on the basis of syntax, this could be done. A 'var' token at that point is never valid, so could get used by a parser to initiate a declaration block, followed by a begin/end block, that the compiler would know how to convert into a separate scope (with unwinding, and auto-calling release on interfaces/reference-counted-instances)...
But it currently doesn't. The closest thing you could get is define an anonymous function and call it once there and then, but that may look ugly and is too much code for what it does, in my humble opinion.
So for now I will just be (re-)using a single s:string;
on top, I'm afraid. (I feel your sqeam, but I'll be really carefull I promise.)
jsonV: plain and simple JSON viewer based on jsonDoc
2016-02-19 21:39 jsonV [permalink]
I decided to create a really simple JSON viewer based on a TTreeView instance and jsonDoc, which itself is heavily based on OleVariants (I really hate long lists of overloads!) so I have some VarType values handled, but show the rest '('+IntToHex(VarType(v),4)+')'
. It could do so much more, but it then would be no longer a really simple JSON viewer. I've commited the source in the jsonDoc repository, see here for a ready-to-run executable (It's an exe in a zip, so some browsers and virus-scanners may cry havok about the security risk):
jsonV.zip (261KB)