If you post some links where I can download a current user
manual and a current compiler or interpreter, I will gladly
withdraw my comment.
Otherwise, I stand by my comment, and see no reason to
consider your alleged environment as anything other than
fiction-ware.
The point of my question is not to determine if something exists but
to find out what the purported language is. I'm tired of hearing
bart brag about his personal programming language but never giving
the specifics of what the language syntax and semantics are. It's
like listening to a used car salesman who won't let you see the
actual car.
I'm not interested in the tools. What I am asking to see is
the language.
I'm working on a document that summaries the features....
But, together with example programs, there should be enough info for someone, already familiar with C, to play with it, given a suitable implementation
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here: https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I posted recently.)
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I
posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
On 18/03/2025 12:17, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I >>> posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
There were some tweaks needed; it indicates some basic info missing from
my write-up! (For example, that the function call needs to be bar() not
bar; 'const' is only for compile-time expressions; and that C's 'const' doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
And below that is that code ported to C. Both versions
produce this output:
Line 1
Line 2
Line 3
Line 4
Line 5
10
Line 1
Line 2
Line 3
Line 4
Line 5
10
Note that both 'b' and 'c' in foo() are used uninitialised. I couldn't
apply 'const' to those, as the const declaration would be separate from
the assignment, and the later assignment is then not possible.
(To answer your presumably implied point, in:
print a
int a:=100
the assignment is done at that place in the code (after print), but the
scope of 'a' is function-wide. My compiler doesn't detect accesses to unitialised variables, but I could add a debug option to clear
stack-frame variables on function entry.)
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
There were some tweaks needed; it indicates some basic info missing from
my write-up! (For example, that the function call needs to be bar() not
bar; 'const' is only for compile-time expressions; and that C's 'const'
doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
Part of the question was if "execution" of declarations is
interleaved with execution of code or if declarations go
before the code.
print a
int a:=100
the assignment is done at that place in the code (after print), but the
scope of 'a' is function-wide. My compiler doesn't detect accesses to
unitialised variables, but I could add a debug option to clear
stack-frame variables on function entry.)
I see. So your feature conflicts with C feature "variable which is initialized at declaration time is always used initialized".
On 18/03/2025 15:10, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
There were some tweaks needed; it indicates some basic info missing from >>> my write-up! (For example, that the function call needs to be bar() not
bar; 'const' is only for compile-time expressions; and that C's 'const'
doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
Part of the question was if "execution" of declarations is
interleaved with execution of code or if declarations go
before the code.
A declaration like:
int a := x
can be considered to be:
int a; a := x
where the declaration can go anywhere in the scope=, but the assignment
must be done here. There are languages where you have:
print x
where x is ...
But the typical usage pattern in my own programs is that local variable
are declared before first use.
(Maybe a compiler option can enforce that, but I don't see it as critical.)
print a
int a:=100
the assignment is done at that place in the code (after print), but the
scope of 'a' is function-wide. My compiler doesn't detect accesses to
unitialised variables, but I could add a debug option to clear
stack-frame variables on function entry.)
I see. So your feature conflicts with C feature "variable which is
initialized at declaration time is always used initialized".
That doesn't happen here:
int a = a;
gcc (with no extra options) tcc and bcc both put some undefined value in a.
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the >use-without-initialisation warnings for this variable". So it makes
perfect sense for the compiler not to warn about it!
"int a = a + 1;", on the other hand, clearly attempts to read the value
of "a" before it is initialised, and a warning is issued if
"-Wuninitialized" is enabled. This warning is part of "-Wall".
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable".
So it makes perfect sense for the compiler not to warn about it!
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
"int a = a + 1;", on the other hand, clearly attempts to read the value
of "a" before it is initialised, and a warning is issued if
"-Wuninitialized" is enabled. This warning is part of "-Wall".
How is: int a = a + 1;
conceptually different from: int a = a;
Both are expressions involving 'a'.
Isn't 'a' being used un-initialised in both cases?
(You have to know the value of 'a' in order to evaluate the expression: a)
On 18.03.2025 19:04, Kenny McCormack wrote:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable".
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable". So it makes
perfect sense for the compiler not to warn about it!
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
"int a = a + 1;", on the other hand, clearly attempts to read the value
of "a" before it is initialised, and a warning is issued if
"-Wuninitialized" is enabled. This warning is part of "-Wall".
How is: int a = a + 1;
conceptually different from: int a = a;
Both are expressions involving 'a'.
Isn't 'a' being used un-initialised in both cases?
(You have to know the value of 'a' in order to evaluate the expression: a)
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the >>use-without-initialisation warnings for this variable". So it makes >>perfect sense for the compiler not to warn about it!
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
[...] A brief check suggests that gcc will generate code as it
would for "int a = 0;", but it is certainly possible for a compiler to
avoid any kind of initialisation here and let the register or stack slot
used for "a" stay as it was. That would be a pretty minor efficiency improvement,
but optimised code is mostly the sum of lots of tiny improvements.
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I >>>> posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
There were some tweaks needed; it indicates some basic info missing from
my write-up! (For example, that the function call needs to be bar() not
bar; 'const' is only for compile-time expressions; and that C's 'const'
doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
Part of the question was if "execution" of declarations is
interleaved with execution of code or if declarations go
before the code.
I am not saying that you should implement this, rejecting the
code as insane would be fine for me.
And below that is that code ported to C. Both versions
produce this output:
Line 1
Line 2
Line 3
Line 4
Line 5
10
Line 1
Line 2
Line 3
Line 4
Line 5
10
Note that both 'b' and 'c' in foo() are used uninitialised. I couldn't
apply 'const' to those, as the const declaration would be separate from
the assignment, and the later assignment is then not possible.
(To answer your presumably implied point, in:
print a
int a:=100
the assignment is done at that place in the code (after print), but the
scope of 'a' is function-wide. My compiler doesn't detect accesses to
unitialised variables, but I could add a debug option to clear
stack-frame variables on function entry.)
I see. So your feature conflicts with C feature "variable which is initialized at declaration time is always used initialized".
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler that
the variable is always initialised before use, but /I/ know it is -
so disable the use-without-initialisation warnings for this
variable". So it makes perfect sense for the compiler not to warn
about it!
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
On 18.03.2025 20:51, David Brown wrote:
[...] A brief check suggests that gcc will generate code as it
would for "int a = 0;", but it is certainly possible for a compiler to
avoid any kind of initialisation here and let the register or stack slot
used for "a" stay as it was. That would be a pretty minor efficiency
improvement,
but optimised code is mostly the sum of lots of tiny improvements.
Interesting view. I've learned that such Peephole Optimizations were
not what contribute to optimizations most. It's rather transformations
of structure of various forms that is what "mostly" matters. - That's
what I've learned many decades ago, of course. - So I'm curious where
you've got that view from. (Some reference, maybe? Or was that just a personal opinion?)
gazelle@shell.xmission.com (Kenny McCormack) writes:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler that
the variable is always initialised before use, but /I/ know it is -
so disable the use-without-initialisation warnings for this
variable". So it makes perfect sense for the compiler not to warn
about it!
An addle-brained view. Anyone who thinks that should be forcibly
removed from any activity involving software development.
(Kenny McCormack) writes:
David Brown wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler that
the variable is always initialised before use, but /I/ know it is -
so disable the use-without-initialisation warnings for this
variable". So it makes perfect sense for the compiler not to warn
about it!
An addle-brained view. Anyone who thinks that should be forcibly
removed from any activity involving software development.
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
There are two problems: one, the semantics are different; and two,
the impression given of the author's intent is different. It's kind
of like saying "isn't it just easier and clearer to write 'red'
rather than 'yellow'?" Writing 'int a = 0;' might be better or it
might be worse, depending on one's point of view, but it shouldn't
be considered either more clear or less clear, because it isn't
saying the same thing.
On 18.03.2025 19:04, Kenny McCormack wrote:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable
is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable".
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
On 18/03/2025 19:36, Janis Papanagnou wrote:
On 18.03.2025 19:04, Kenny McCormack wrote:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable >>>> is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable".
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
It is certainly an idiom, and certainly viewed by gcc as a way to avoid
an "uninitialized" warning (unless "-Winit-self" is also enabled), and
it is an idiom I have seen documented in at least one other compiler
(though I can't remember which - I've read many compiler manuals over
the decades).
But judging from the posts here, it may not be a "common" idiom.
(And I am not suggesting it is a /good/ idiom. It's not one I use
myself, and I have "-Winit-self" in my list of standard warning flags
because it is conceivable that I write "int a = a;" in error. But there
are lots of idioms and common practices in C that I don't like personally.)
As far as I understand it (and I hope to be corrected if I am wrong),
"int a = a;" is not undefined behaviour as long as the implementation
does not have trap values for "int". It simply leaves "a" as an
unspecified value - just like "int a;" does. Thus it is not in any way >"worse" than "int a;" as far as C semantics are concerned. Any
difference is a matter of implementation - and the usual implementation >effect is to disable "not initialised" warnings.
It is in much the same category as "(void) x;", which is an idiom for >skipping an "unused variable" or "unused parameter" warning.
On 18/03/2025 19:36, Janis Papanagnou wrote:
On 18.03.2025 19:04, Kenny McCormack wrote:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a common
idiom meaning "I know it is not clear to the compiler that the variable >>>> is always initialised before use, but /I/ know it is - so disable the
use-without-initialisation warnings for this variable".
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
It is certainly an idiom, and certainly viewed by gcc as a way to avoid
an "uninitialized" warning (unless "-Winit-self" is also enabled), and
it is an idiom I have seen documented in at least one other compiler
(though I can't remember which - I've read many compiler manuals over
the decades).
David Brown <david.brown@hesbynett.no> writes:
On 18/03/2025 19:36, Janis Papanagnou wrote:
On 18.03.2025 19:04, Kenny McCormack wrote:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler
that the variable is always initialised before use, but /I/ know
it is - so disable the use-without-initialisation warnings for
this variable".
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
It is certainly an idiom, and certainly viewed by gcc as a way to
avoid an "uninitialized" warning (unless "-Winit-self" is also
enabled), and it is an idiom I have seen documented in at least one
other compiler (though I can't remember which - I've read many
compiler manuals over the decades).
But judging from the posts here, it may not be a "common" idiom.
(And I am not suggesting it is a /good/ idiom. It's not one I use
myself, and I have "-Winit-self" in my list of standard warning
flags because it is conceivable that I write "int a = a;" in error.
But there are lots of idioms and common practices in C that I don't
like personally.)
As far as I understand it (and I hope to be corrected if I am
wrong), "int a = a;" is not undefined behaviour as long as the
implementation does not have trap values for "int". It simply
leaves "a" as an unspecified value - just like "int a;" does. Thus
it is not in any way "worse" than "int a;" as far as C semantics
are concerned. Any difference is a matter of implementation - and
the usual implementation effect is to disable "not initialised"
warnings.
It is in much the same category as "(void) x;", which is an idiom
for skipping an "unused variable" or "unused parameter" warning.
I would disagree with this last statement. (void)x is genuinely
useful and has no ill side effects. 'int a = a;' is exactly
the opposite - not useful and has potenial bad side effects.
On Tue, 18 Mar 2025 23:52:20 -0700, Tim Rentsch wrote:
(Kenny McCormack) writes:
David Brown wrote:
...
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler
that the variable is always initialised before use, but /I/
know it is - so disable the use-without-initialisation warnings
for this variable". So it makes perfect sense for the compiler
not to warn about it!
An addle-brained view. Anyone who thinks that should be forcibly
removed from any activity involving software development.
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
There are two problems: one, the semantics are different; and
two, the impression given of the author's intent is different.
It's kind of like saying "isn't it just easier and clearer to
write 'red' rather than 'yellow'?" Writing 'int a = 0;' might be
better or it might be worse, depending on one's point of view,
but it shouldn't be considered either more clear or less clear,
because it isn't saying the same thing.
int a=a;
for me initialize "a" variable with a value the compiler found
right as in
int a;
only possibly silence compiler warning for variable not
initializated
The scares me a bit:
_____________________
#include <stdio.h>
int main() {
int a = 666;
{
// Humm... Odd to me...
int a = a;
printf("%d", a);
}
return 0;
}
On 19/03/2025 22:29, Chris M. Thomasson wrote:
The scares me a bit:
_____________________
#include <stdio.h>
int main() {
int a = 666;
{
// Humm... Odd to me...
int a = a;
printf("%d", a);
}
return 0;
}
Yes, that is an unfortunate consequence of the scoping in C - on the
line "int a = a;", the new "a" is initialised with its own unspecified
value, not with the value of the outer "a".
If the scope of the new variable did not start until after the initialisation, then it would have allowed a number of possibilities
that would be a lot more useful than the "disable warnings about uninitialised variables" effect or initialisers which refer to their own address. For example :
int a = 123;
{
int a = a;
// local copy that does not affect the outer one
...
int a = 123;
{
long long int a = a;
// Local copy that with expanded size
...
for (int a = 0; a < 100; a++) {
const int a = a;
// "Lock" the loop index to catch errors
As it is, you need to do something like :
for (int a = 0; a < 100; a++) {
const int _a = a;
const int a = _a;
// "Lock" the loop index to catch errors
On 20/03/2025 08:39, David Brown wrote:
On 19/03/2025 22:29, Chris M. Thomasson wrote:
The scares me a bit:
_____________________
#include <stdio.h>
int main() {
int a = 666;
{
// Humm... Odd to me...
int a = a;
printf("%d", a);
}
return 0;
}
Yes, that is an unfortunate consequence of the scoping in C - on the
line "int a = a;", the new "a" is initialised with its own unspecified
value, not with the value of the outer "a".
So the inner 'a' wasn't supposed to mysteriously inherit the outer a's
value? (Perhaps due to sharing the same location.) Since the compilers I tried just showed zero not 666.
If the scope of the new variable did not start until after the
initialisation, then it would have allowed a number of possibilities
that would be a lot more useful than the "disable warnings about
uninitialised variables" effect or initialisers which refer to their
own address. For example :
int a = 123;
{
int a = a;
// local copy that does not affect the outer one
...
int a = 123;
{
long long int a = a;
// Local copy that with expanded size
...
for (int a = 0; a < 100; a++) {
const int a = a;
// "Lock" the loop index to catch errors
As it is, you need to do something like :
for (int a = 0; a < 100; a++) {
const int _a = a;
const int a = _a;
// "Lock" the loop index to catch errors
You mean locking the loop index so it can't be modified?
scott@slp53.sl.home (Scott Lurndal) writes:
I would disagree with this last statement. (void)x is genuinely
useful and has no ill side effects. 'int a = a;' is exactly
the opposite - not useful and has potenial bad side effects.
I concur except that I recommend using (void)&x rather than (void)x,
because (void)&x is safer. If x is volatile qualified, for example,
the expression (void)x actually does something, and must not be
compiled away, whereas (void)&x does not have these properties.
On 18/03/2025 15:10, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
I see. So your feature conflicts with C feature "variable which is
initialized at declaration time is always used initialized".
That doesn't happen here:
int a = a;
gcc (with no extra options) tcc and bcc both put some undefined value in a.
gcc won't warn until you say '-Wextra', and then only for:
int a = a + 1;
On 18/03/2025 15:10, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I >>>>> posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
There were some tweaks needed; it indicates some basic info missing from >>> my write-up! (For example, that the function call needs to be bar() not
bar; 'const' is only for compile-time expressions; and that C's 'const'
doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
In this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
bart <bc@freeuk.com> wrote:
On 18/03/2025 15:10, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I >>>>>> posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
There were some tweaks needed; it indicates some basic info missing from >>>> my write-up! (For example, that the function call needs to be bar() not >>>> bar; 'const' is only for compile-time expressions; and that C's 'const' >>>> doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
In this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
In your description you wrote that declarations can be written
"out of order" and compiler will rearrange them in correct
order. That looked like great opportunity to write obfuscated
code.
(mlet ((a (lcons 1 b))(b (lcons 0 a)))
(mlet ((a (cons 1 b))(b (cons 0 a)))
(mlet ((x (+ y 3))(z (+ x 1))
bart <bc@freeuk.com> wrote:
On 18/03/2025 15:10, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
On 18/03/2025 12:17, Waldek Hebisch wrote:
bart <bc@freeuk.com> wrote:
This is the document I produced:
https://github.com/sal55/langs/blob/master/MFeatures.md
A couple of more substantial demo programs are here:
https://github.com/sal55/langs/tree/master/MExamples
(The bignum.m file was ported - by hand - to the bignum.c version that I >>>>>> posted recently.)
Looking at features, can you say if the program below works?
And if it works, what is retrun value of foo? "Equvalent" can
be written in C, but in C you have to keep sane order.
There were some tweaks needed; it indicates some basic info missing from >>>> my write-up! (For example, that the function call needs to be bar() not >>>> bar; 'const' is only for compile-time expressions; and that C's 'const' >>>> doesn't exist - it only briefly mentions an attempt at 'let'.)
The revised code is shown below, with what I assumed were your
intentions.
Well, my intentions beter correspond to the C version below:
int foo() {
const int c = c1(10);
const int b = c + c2(2);
const int a = b+c3(c);
bar();
baz();
return c;
}
In this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
In your description you wrote that declarations can be written
"out of order" and compiler will rearrange them in correct
order.
That looked like great opportunity to write obfuscated
code.
As you explained, it works differently, but I think
already the fixed version of code I gave shows potential.
And the following seem to satisfy your restriction that
'const' is compile time constant and what happens is
puzzling to the reader (better than goto-s used to confuse
control flow):
func foo:int =
const a = b + c
let int cc := c1(a)
const b = c + 2
let int bb := c2(b) + cc
const c = 10
bb + c
end
On 2025-03-20, Waldek Hebisch <antispam@fricas.org> wrote:>> In your description you wrote that declarations can be written
bart <bc@freeuk.com> wrote:
In this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
"out of order" and compiler will rearrange them in correct
order. That looked like great opportunity to write obfuscated
code.
I made a language feature like that: mlet.
https://www.nongnu.org/txr/txr-manpage.html#N-2B3072E9
This allows for circular references in order to support
the construction of lazy objects:
(mlet ((a (lcons 1 b))(b (lcons 0 a)))
(take 20 a))
(1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)
On 20/03/2025 23:45, Kaz Kylheku wrote:
On 2025-03-20, Waldek Hebisch <antispam@fricas.org> wrote:
bart <bc@freeuk.com> wrote:
>> In your description you wrote that declarations can be writtenIn this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
"out of order" and compiler will rearrange them in correct
order. That looked like great opportunity to write obfuscated
code.
I made a language feature like that: mlet.
https://www.nongnu.org/txr/txr-manpage.html#N-2B3072E9
This allows for circular references in order to support
the construction of lazy objects:
(mlet ((a (lcons 1 b))(b (lcons 0 a)))
(take 20 a))
(1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)
I don't understand what's going on above; the example here is a bit
clearer, other than that z at the end:
(mlet ((x (+ y 1))
(y (+ z 1))
(z (+ x 1)))
z)
But this looks like something that goes on at runtime. In the language
above, it's all dealt with at compile time. If I create a similar example:
const x = y + 1,
y = z + 1,
z = x + 1
then it is the compiler that reports a circular reference.
Otherwise, in my dynamic (and non-lazy) language, circular references
are allowed at runtime, but it is object references rather than names:
a ::= (1,2,3) # create two short lists (::= makes a mutable copy)
b ::= (4,5,6)
a &:= b # append each to the other (concatenate is
b &:= a # well-behaved)
On 2025-03-21, bart <bc@freeuk.com> wrote:
On 20/03/2025 23:45, Kaz Kylheku wrote:
On 2025-03-20, Waldek Hebisch <antispam@fricas.org> wrote:
bart <bc@freeuk.com> wrote:
In this case, just write it like that, and only adjust it for the
somewhat different syntax:
func foo:int =
let int c := c1(10)
let int b := c + c2(2)
let int a := b+c3(c)
bar()
baz()
return c
end
>> In your description you wrote that declarations can be written
"out of order" and compiler will rearrange them in correct
order. That looked like great opportunity to write obfuscated
code.
I made a language feature like that: mlet.
https://www.nongnu.org/txr/txr-manpage.html#N-2B3072E9
This allows for circular references in order to support
the construction of lazy objects:
(mlet ((a (lcons 1 b))(b (lcons 0 a)))
(take 20 a))
(1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)
I don't understand what's going on above; the example here is a
bit clearer, other than that z at the end:
What's going on is that [...]
antispam@fricas.org (Waldek Hebisch) writes:
[...]
Well, it is rather easy to see if variable is used within its
own initialization, so practically it is minor gap. Of course,
there is problem with C standard: IIUC depending on rest of
the code declarations as above are merely undefined behaviour
or even produce unspecified value. So C compiler is
forbidden to stop compilation are report compile time error.
Valid responses to undefined behavior include "terminating a translation
or execution (with the issuance of a diagnostic message)". In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:...
Valid responses to undefined behavior include "terminating a translation
or execution (with the issuance of a diagnostic message)". In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
This was probably subject to previous disscussion here, IIRC
some posters here claimed that even in such case implementation
is supposed to produce an executable.
However, certainly
implementation must accept the program when code that would
exhibit undefined behaviour is not executed. And in practice
when using separate compilation compiler normally is not
able to decide if a function will be called or not (and even
when whole program is available compiler still have halting
problem to solve). So cases when compiler is allowed to report
compilation error are quite limite in practice.
On 3/22/25 10:37, Waldek Hebisch wrote:
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:...
Valid responses to undefined behavior include "terminating a translation >>> or execution (with the issuance of a diagnostic message)". In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
This was probably subject to previous disscussion here, IIRC
some posters here claimed that even in such case implementation
is supposed to produce an executable.
There is no such requirement. Could you identify who made such a claim,
when, with what arguments? My newserver's archives only go back three
months, and if the claim was made by somebody I've got killfiled, I
won't be able to see it even during that time period. Google Groups
stopped archiving new messages quite a while ago. Therefore, it might be
best to quote the relevant text, rather than merely identifying it.
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
On 3/22/25 10:37, Waldek Hebisch wrote:
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:...
Valid responses to undefined behavior include "terminating a translation >>>> or execution (with the issuance of a diagnostic message)". In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
This was probably subject to previous disscussion here, IIRC
some posters here claimed that even in such case implementation
is supposed to produce an executable.
There is no such requirement. Could you identify who made such a claim,
when, with what arguments? My newserver's archives only go back three
months, and if the claim was made by somebody I've got killfiled, I
won't be able to see it even during that time period. Google Groups
stopped archiving new messages quite a while ago. Therefore, it might be
best to quote the relevant text, rather than merely identifying it.
Sorry, is would be quite a lot of work to find relevant messages.
antispam@fricas.org (Waldek Hebisch) writes:
[...]
Well, it is rather easy to see if variable is used within its
own initialization, so practically it is minor gap. Of course,
there is problem with C standard: IIUC depending on rest of
the code declarations as above are merely undefined behaviour
or even produce unspecified value. So C compiler is
forbidden to stop compilation are report compile time error.
Valid responses to undefined behavior include "terminating a translation
or execution (with the issuance of a diagnostic message)".
In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (0 / 16) |
Uptime: | 155:54:45 |
Calls: | 10,384 |
Calls today: | 1 |
Files: | 14,056 |
Messages: | 6,416,464 |