Well, tasks are not only for speeding up code. They can be a very useful design tool (active objects, independant activities). I think the Ada
model is clean and simple, I would hate to see it disappear.
I'm less certain about the value of priorities, [...]
Priorities are just optimization on how to manage cores when there are
not enough of them.
I know that people use priorities to guarantee mutual exclusion, and
other properties. All these algorithms were designed at the time of
mono-CPU machines, but they fail on multi-cores.
If Ada did not have tasks with priorities, most of the Ada applications
I have worked on in my life would have had to avoid Ada tasking and
retreat to using some other real-time kernel, with ad-hoc mapping of the >kernels's threads to Ada procedures.
If Ada did not have tasks with priorities, most of the Ada
applications I have worked on in my life would have had to avoid Ada
tasking and retreat to using some other real-time kernel, with ad-hoc
mapping of the kernels's threads to Ada procedures.
Counter intuitively it is possible that this is holding Ada back. A lot of Ada code cannot run without some fairly complex runtime support due to
tasks, protected objects, finalization etc.. Runtimes have to be developed for each chip instead of each cpu.
If you need advanced multi core support then using an OS seems like a more suitable situation to be in to me.
"Lawrence D'Oliveiro" <ldo@nz.invalid> wrote in message news:vbdk2t$hj0r$6@dont-email.me...
On Thu, 5 Sep 2024 19:03:22 -0500, Randy Brukardt wrote:...
(10) Variable-returning functions are introduced.
Is this like updater functions in POP-11, or "setf" in Lisp?
No, it is a function that returns a variable, meaning you can assign
into the function result.
Priorities are just optimization on how to manage cores when there are
not enough of them.
In some contexts it could be optimization -- for example, to increase throughput in a soft real-time system -- but in hard real-time systems priorities (or deadlines) are needed for correctness, not just for optimizatiion.
Ok, I understand. In that case, what "parallel" adds to the current
tasking feature is an easy way to create a largish and perhaps dynamically defined number of concurrent threads from a "parallel" loop, where the threads are automatically created when the loop is started and
automatically "joined" and destroyed when the loop completes.
On Wed, 11 Sep 2024 23:39:27 -0500, Randy Brukardt wrote:
"Lawrence D'Oliveiro" <ldo@nz.invalid> wrote in message
news:vbdk2t$hj0r$6@dont-email.me...
On Thu, 5 Sep 2024 19:03:22 -0500, Randy Brukardt wrote:...
(10) Variable-returning functions are introduced.
Is this like updater functions in POP-11, or "setf" in Lisp?
No, it is a function that returns a variable, meaning you can assign
into the function result.
I think an updater function would be more generally useful. Because some things you want to update might not (depending on the implementation) live independently in an explicit variable. And it seems good not to constrain implementations unnecessarily.
I think the parallel block is more useful for general tasking. The advantage of using parallel structures is that they look very similar to sequential structures, and one lets the system do the scheduling (rather than trying to figure out an organization manually).
One of the advantages of the model I'm thinking about is that it separates concerns such as parallel execution, mutual exclusion, inheritance, organization (privacy, type grouping), and so on into separate (mostly) non-overlapping constructs.
Ada started this process by having tagged types
a separate construct from packages;
but you can also construct many structures that are quite hard in
traditional "one construct" OOP. I think that ought to be done for all constructs, and thus the special task and protected constructs ought to go.
We already know that protected types cause problems with privacy of implementation and with inheritance. Tasks have similar issues (admittedly less encountered), so splitting them into a set of constructs would fit the model.
Unfortunately, "updater" functions don't work with the Ada model of components, because you can't tell what to do when a component appears
or disappears in an assignment.
... priorities never help for correctness.
"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message news:lkg1vvF1tp6U1@mid.individual.net...
...
Priorities are just optimization on how to manage cores when there are
not enough of them.
In some contexts it could be optimization -- for example, to increase
throughput in a soft real-time system -- but in hard real-time systems
priorities (or deadlines) are needed for correctness, not just for
optimizatiion.
This I don't buy: priorities never help for correctness. At least not
without extensive static analysis, but if you can do that, you almost certainly can do the correctness without depending upon priorities.
(3) A number of syntax options are eliminated. Matching identifiers are required at the end of subprograms and packages. Initializers are always required (<> can be used if default initialization is needed). Keyword "variable" is needed to declare variables (we do not want the worst option
to be the easiest to write, as it is in Ada).
(10) Variable-returning functions are introduced. They're pretty similar the semantics of anonymous access returns (or the aliased function returns suggested by Tucker). This means that a variable can easily be treated as a function (and indeed, a variable declaration is just syntactic sugar for
such a function).
Square (2) := 3;
List.Index (3) := Item;
Le 06/09/2024 02:03, Randy Brukardt a crit :
(3) A number of syntax options are eliminated. Matching identifiers are
required at the end of subprograms and packages. Initializers are always
required (<> can be used if default initialization is needed). Keyword
"variable" is needed to declare variables (we do not want the worst
option
to be the easiest to write, as it is in Ada).
Why are you considering variables worst than constants?
I don't want the the "worst" option to be the easiest to write, but
neither do I want to put one more keyword in the most common case.
Note that :
1. I have no statistics, but it seems to me that there is more variables than constants in my code.
2. I say "Useless" from my coder point of view, I dont know if it simplify the work for compiler or tools implementers.
Le 06/09/2024 02:03, Randy Brukardt a crit :
(10) Variable-returning functions are introduced. They're pretty similar
the
semantics of anonymous access returns (or the aliased function returns
suggested by Tucker). This means that a variable can easily be treated as >> a
function (and indeed, a variable declaration is just syntactic sugar for
such a function).
I suppose that to allows the compiler to discriminate this non sense code
Square (2) := 3;
from the legitimate
List.Index (3) := Item;
you will have to introduce some specific syntax, like Tucker's "aliased function".
I see the huge benefit from a user point of view, but I'm not aware of compiler internals : doesn't the introduction of a second function type increase complexity?
"One more keyword" is irrelevant in terms of creating code, the only
question is whether it hurts readability.
But how many of them *have* to be variables vs. the number that just are because it is easier? I know I have a number of the latter.
Note that :
1. I have no statistics, but it seems to me that there is more variables
than constants in my code.
But how many of them *have* to be variables vs. the number that just are because it is easier? I know I have a number of the latter.
2. I say "Useless" from my coder point of view, I dont know if it simplify >> the work for compiler or tools implementers.
Constants do help the compiler generate better code, although a lot of the benefits can be gained also by working harder. (That's what C compilers do, after all.)
On 21.12.24 09:14, Randy Brukardt wrote:
Note that :
1. I have no statistics, but it seems to me that there is more variables >>> than constants in my code.
But how many of them *have* to be variables vs. the number that just are
because it is easier? I know I have a number of the latter.
2. I say "Useless" from my coder point of view, I dont know if it
simplify
the work for compiler or tools implementers.
Constants do help the compiler generate better code, although a lot of
the
benefits can be gained also by working harder. (That's what C
compilers do,
after all.)
What are some compilers offering today? That is, can they find declarations of variables that could be constants, if so instructed?
I am seeing some warnings about non-initialized variables for a meaningless mock-up, but not much else. Ada, C++, Java.
(Maybe there are options that I have missed. Or an analysis of a whole program yields more.)
function testc (b : Boolean) return Integer is
package P is
x : Integer;
end;
begin
if b then
P.x := 42;
end if;
return P.x;
end testc;
int testc(bool b) {
struct {
int x;
} P;
if (b) {
P.x = 42;
}
return P.x;
}
class testc {
class P {
int x;
}
P P;
int $(boolean b) {
if (b) {
P.x = 42;
}
return P.x;
}
}
A lot of "variables" in code actually are only written once. In Ada, those are better modeled as constants. A constant tells the reader that the value doesn't change during the life of the object, which is easier for analysis (both human and machine).[...]
Using "constant" for something that isn't going to be modified isExactly the point of Randy. And as Jean-Pierre would say "a program is
good
practice, but I'd say it's for the benefit of the human reader.
I am seeing some warnings about non-initialized variables for a meaningless mock-up, but not much else.
"G.B." <bauhaus@notmyhomepage.invalid> writes:
I am seeing some warnings about non-initialized variables for a meaningless >> mock-up, but not much else.
See -gnatwk, which is included in -gnatwa. Been around for a long time now.
On 22.12.24 13:15, Simon Wright wrote:
"G.B." <bauhaus@notmyhomepage.invalid> writes:
I am seeing some warnings about non-initialized variables for a meaningless >>> mock-up, but not much else.See -gnatwk, which is included in -gnatwa. Been around for a long
time now.
No effect of either here (gcc-14.1.0). I see a CONSTRAINT_ERROR at run time when using the uninitialized return value, for indexing an array.
What are some compilers offering today? That is, can they find
declarations of variables that could be constants, if so instructed?
I put a lot of effort into making sure that all constants are so declared, because I have the rule that (with certain exceptions) no non-local variables may be referenced from subprograms, but constants may be referenced from anywhere.
However, I sometimes have constants that cannot be initialized with a
single expression, resulting in
C : T; -- Constant after initialization
Once C has been initialized, I treat it as a constant. Would your approach allow the compiler to know that C is really a constant?
--
Jeff Carter
"Anyone who cannot cope with mathematics
is not fully human."
The Notebooks of Lazarus Long
214
On 21.12.24 09:14, Randy Brukardt wrote:...
Constants do help the compiler generate better code, although a lot of
the
benefits can be gained also by working harder. (That's what C compilers
do,
after all.)
What are some compilers offering today? That is, can they find
declarations
of variables that could be constants, if so instructed?
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,104 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492394:31:42 |
| Calls: | 14,151 |
| Calls today: | 2 |
| Files: | 186,281 |
| D/L today: |
12,088 files (3,845M bytes) |
| Messages: | 2,501,352 |
| Posted today: | 1 |