Forum > General
Nested procedures
Thaddy:
--- Quote from: Ten_Mile_Hike on June 13, 2024, 10:59:40 pm ---============
ECHO. |TIME
============
--- End quote ---
That is called function chaining and is already possible in object pascal.
two examples are:
- component create functions that return self (KOL works like that)
- pipes (that's how echo | time works )
MarkMLl:
--- Quote from: Ten_Mile_Hike on June 13, 2024, 10:59:40 pm ---I wonder if the Pascal Gods would be angered if I tried to implement this
in Pascal just as an exercise (in frustration). I might try by using pointers
in some naughty way.
--- End quote ---
Should be easy enough with a couple of TProcesses, but will need a code fragment between them to transfer the data... you might be able to hook OnRunCommandEvent for that.
Otherwise just use the shell as the binary, as nature intended:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---/bin/sh -c "echo -n C`svnversion -n`C |tr A-G %-+ >project_svnrevision.inc & echo -n C`svnversion -n $FPCSrcDir()`C |tr A-G %-+>fpc_svnrevision.inc"
That's something that I routinely use before Lazarus builds a project, and the IDE passes that more or less directly to a TProcess. As you can see, it exercises shell syntax fairly thoroughly, together with path resolution etc.
MarkMLl
VisualLab:
--- Quote from: Thaddy on June 13, 2024, 01:26:24 pm ---We can not yet write a restriction like str<T:ordinal> but it is considered to be implemented. Once it is, this code would be very safe.
I show this, because this new feature of implicit specialization is very powerful and I recently started to use it a lot. (but I don't have to write production code anymore.....)
--- End quote ---
Have I understood correctly that it will be possible to use constraints on generic types? (e.g.: ordinal, enumeration, numeric?) Will there be constraints for numeric types too? (e.g.: integer, real?)
Thaddy:
Numeric types sec are ordinals (of course not float types)
We already have constraints for classes and records.
My outstanding feature request is about just ordinals, which includes by their very nature all integer types and enumerations. It is well received.
So where we can now already limit a generic to a class or record, we would be able to write somegeneric<T:Ordinal> which makes it type safe for any type that can be expressed as an ordinal.
--- Quote --- (e.g.: ordinal, enumeration, numeric?)
--- End quote ---
All of these fall in the category ordinal. It would be the specialization that determines what kind of ordinal, just as with class and record restrictions.
I have not thought about a float restriction. I see less use for it. Floats have only one typekind, just tkFloat, which can easily be handled by overloads. Ordinal values have multiple typekinds. See:
https://www.freepascal.org/docs-html/rtl/system/ttypekind.html
Although in both cases you can already do things like this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---generic function testme<T>(const value:T):T;begin Assert(GetTypeKind(value)= tkFloat,'is not a float'); //work with Tend;
Navigation
[0] Message Index
[*] Previous page