Discussion:
on named blocks concept
(too old to reply)
fir
2024-11-06 16:04:28 UTC
Permalink
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like

foo {
//code here
}

whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions

int foo() {
a { }
b { }
}

then it could be called internally

int foo() {
a { }
b { }

int x = a()*a()*b(); //though imo () probab;ly should be optionall
}

or externally

foo.a()

those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation is
bad imo)

if so mant things can be done with this blocks probably, im not exactly
sure what exactly

ona assembly label blocks by defauld probably be done by

name:
//...
ret

so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)

overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables

foo {
a {}

int x, y = a(1,2)
}

though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)

a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}

or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}

as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use

this concept is yet not fully build yet but what i descrbed her i guess
is okay
Thiago Adams
2024-11-06 18:46:13 UTC
Permalink
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
  //code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
  a { }
  b { }
}
then it could be called internally
int foo() {
  a { }
  b { }
  int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation is
bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
  //...
  ret
 so then can be reused though some version to call it in place
 of definitions could be also avaliable imo (something like
 a{}() in a sense but better looking (this looks to bad)
 overally those named block should be also united with function
 so they become the same if use on them the functionality of
 passing arguments and returning variables
 foo {
   a {}
   int x, y = a(1,2)
 }
 though i maybe not sure how to add this mechanism
 possibly som,ething liek this (until something better could be found)
 a
 {
  in int c;
  in int d;
  out int x = c+d;
  out int y = c-d;
 }
 or
 a( int c, int d)
 {
  out int x = c+d;
  out int y = c-d;
 }
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i guess
is okay
Names loops (only loops) were proposed to C2Y.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Thiago Adams
2024-11-06 19:00:30 UTC
Permalink
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
   //code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
   a { }
   b { }
}
then it could be called internally
int foo() {
   a { }
   b { }
   int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
   //...
   ret
  so then can be reused though some version to call it in place
  of definitions could be also avaliable imo (something like
  a{}() in a sense but better looking (this looks to bad)
  overally those named block should be also united with function
  so they become the same if use on them the functionality of
  passing arguments and returning variables
  foo {
    a {}
    int x, y = a(1,2)
  }
  though i maybe not sure how to add this mechanism
  possibly som,ething liek this (until something better could be found)
  a
  {
   in int c;
   in int d;
   out int x = c+d;
   out int y = c-d;
  }
  or
  a( int c, int d)
  {
   out int x = c+d;
   out int y = c-d;
  }
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
fir
2024-11-06 19:17:25 UTC
Permalink
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
//code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
a { }
b { }
}
then it could be called internally
int foo() {
a { }
b { }
int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
//...
ret
so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)
overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables
foo {
a {}
int x, y = a(1,2)
}
though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)
a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}
or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
no, it simply gives you more 'power' in code (in means of expression)
generally speaking... specifically it may give you various things
but hard to name the possible usacases as it will eventually show

you eventually can think on it itself


it also (as its logical basic concept) gives some thoughts on how
functions are badly done in c - becouse the "stack based" locals
and arguments are bad imo..without it you may do more "tricks"
with code making your code can be shorter and clever sometimes imo
fir
2024-11-06 19:46:16 UTC
Permalink
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
//code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
a { }
b { }
}
then it could be called internally
int foo() {
a { }
b { }
int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
//...
ret
so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)
overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables
foo {
a {}
int x, y = a(1,2)
}
though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)
a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}
or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions

a {printf("\n %d", i)}

void foo(int n, block p)
{
for(int i=0; i<n; i++) p();
}

foo(10,a);


its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just a
name so this is more liek piece of text not a real code here

eventualy some coud do

a(int i) {printf("\n %d", i)}

void foo(int n, block p)
{
for(int i=0; i<n; i++) p(i);
}

foo(10,a);

so this is like passing conceptually function to function but not a pointer

but this is all side topic here

more strightforward would be how to do this block arithmetic


a {}
b{ }
c{}

int x = a*b+c;

where a,b,c are blocks of code (though here it would probably mean "run
a" get value and mul by "run b" take value , tun c and add
Thiago Adams
2024-11-06 20:24:48 UTC
Permalink
Post by fir
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
   //code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
   a { }
   b { }
}
then it could be called internally
int foo() {
   a { }
   b { }
   int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
   //...
   ret
  so then can be reused though some version to call it in place
  of definitions could be also avaliable imo (something like
  a{}() in a sense but better looking (this looks to bad)
  overally those named block should be also united with function
  so they become the same if use on them the functionality of
  passing arguments and returning variables
  foo {
    a {}
    int x, y = a(1,2)
  }
  though i maybe not sure how to add this mechanism
  possibly som,ething liek this (until something better could be found)
  a
  {
   in int c;
   in int d;
   out int x = c+d;
   out int y = c-d;
  }
  or
  a( int c, int d)
  {
   out int x = c+d;
   out int y = c-d;
  }
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions
a {printf("\n %d", i)}
void foo(int n, block p)
{
  for(int i=0; i<n; i++) p();
}
foo(10,a);
its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just a
name so this is more liek piece of text not a real code here
eventualy some coud do
a(int i) {printf("\n %d", i)}
void foo(int n, block p)
{
  for(int i=0; i<n; i++) p(i);
}
foo(10,a);
This is one of the lambda motivations.
fir
2024-11-06 20:45:34 UTC
Permalink
Post by Thiago Adams
Post by fir
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
//code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
a { }
b { }
}
then it could be called internally
int foo() {
a { }
b { }
int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
//...
ret
so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)
overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables
foo {
a {}
int x, y = a(1,2)
}
though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)
a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}
or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions
a {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p();
}
foo(10,a);
its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just
a name so this is more liek piece of text not a real code here
eventualy some coud do
a(int i) {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p(i);
}
foo(10,a);
This is one of the lambda motivations.
maybe , but thsi is just a kinda detail here, as it is not so much
difference than passing pointer though it is a difference

(liek when you pass pointer code takes pointer and here if you pass blck
it acan be simpli compiled in in compile time (and thus it is possible
it can have acces to its all parent fuunction variables).. or may be
called in this "lambda " way as far as i remember that

repeat(10, {printf("zzz")} ); //when reepat is a functin that takes block

but as i said probbaly those blocks could be used for some more things
Bart
2024-11-06 21:49:50 UTC
Permalink
Post by fir
Post by Thiago Adams
Post by fir
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
   //code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
   a { }
   b { }
}
then it could be called internally
int foo() {
   a { }
   b { }
   int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
   //...
   ret
  so then can be reused though some version to call it in place
  of definitions could be also avaliable imo (something like
  a{}() in a sense but better looking (this looks to bad)
  overally those named block should be also united with function
  so they become the same if use on them the functionality of
  passing arguments and returning variables
  foo {
    a {}
    int x, y = a(1,2)
  }
  though i maybe not sure how to add this mechanism
  possibly som,ething liek this (until something better could be found)
  a
  {
   in int c;
   in int d;
   out int x = c+d;
   out int y = c-d;
  }
  or
  a( int c, int d)
  {
   out int x = c+d;
   out int y = c-d;
  }
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions
a {printf("\n %d", i)}
void foo(int n, block p)
{
   for(int i=0; i<n; i++) p();
}
foo(10,a);
its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just
a name so this is more liek piece of text not a real code here
eventualy some coud do
a(int i) {printf("\n %d", i)}
void foo(int n, block p)
{
   for(int i=0; i<n; i++) p(i);
}
foo(10,a);
This is one of the lambda motivations.
maybe , but thsi is just a kinda detail here, as it is not so much
difference than passing pointer though it is a difference
(liek when you pass pointer code takes pointer and here if you pass blck
it acan be simpli compiled in in compile time (and thus it is possible
it can have acces to its all parent fuunction variables).. or may be
called in this "lambda " way as far as i remember that
repeat(10, {printf("zzz")} ); //when reepat is a functin that takes block
but as i said probbaly those blocks could be used for some more things
Some of this stuff, like local functions, is in gnu C.

Most other complex stuff, passing lamda functions, you will find in C++.

But unless it is already in gnu, or has been added to C23 (which may
take a decade to become common), C is not going to acquire any random
proposals that you make in threads like this.

At best you might modify one implementation to try out an idea.

I'm not really into either, but I have tried anonymous functions
(without closures) in my scripting language. Your example looks like
this (using near-identical syntax):

proc myrepeat(n, body) =
to n do
body()
end
end

proc main =
myrepeat(10, {printf("zzz")})
end

The lack of closures means the anonymous function inside {...} can't
access any stack-based names outside which are part of the enclosing
function.
fir
2024-11-06 22:43:05 UTC
Permalink
Post by Bart
Post by fir
Post by Thiago Adams
Post by fir
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
//code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
a { }
b { }
}
then it could be called internally
int foo() {
a { }
b { }
int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
//...
ret
so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)
overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables
foo {
a {}
int x, y = a(1,2)
}
though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)
a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}
or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions
a {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p();
}
foo(10,a);
its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just
a name so this is more liek piece of text not a real code here
eventualy some coud do
a(int i) {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p(i);
}
foo(10,a);
This is one of the lambda motivations.
maybe , but thsi is just a kinda detail here, as it is not so much
difference than passing pointer though it is a difference
(liek when you pass pointer code takes pointer and here if you pass blck
it acan be simpli compiled in in compile time (and thus it is possible
it can have acces to its all parent fuunction variables).. or may be
called in this "lambda " way as far as i remember that
repeat(10, {printf("zzz")} ); //when reepat is a functin that takes block
but as i said probbaly those blocks could be used for some more things
Some of this stuff, like local functions, is in gnu C.
Most other complex stuff, passing lamda functions, you will find in C++.
But unless it is already in gnu, or has been added to C23 (which may
take a decade to become common), C is not going to acquire any random
proposals that you make in threads like this.
At best you might modify one implementation to try out an idea.
I'm not really into either, but I have tried anonymous functions
(without closures) in my scripting language. Your example looks like
proc myrepeat(n, body) =
to n do
body()
end
end
proc main =
myrepeat(10, {printf("zzz")})
end
The lack of closures means the anonymous function inside {...} can't
access any stack-based names outside which are part of the enclosing
function.
normally this {printf("zzz")} cant acces not opnly stack based but any
local variables imo... (by 'normally' i mean without breaking some
present default rules.. i mean it in fact aces any like

foo({printf("zzz%d%d%d",a,b,c)}); but it just mean it more work like c++
template which "lives" only before compilation - as here a,b,c are just
texts which can be resolved at compile time to different things

- and this is not neccesart the thing im thinking about here (generally
i prefer the constructs that live after compilation, but those
eventually also could be considered

thoce stack based variables and arguments are bad for other reasons..
generally the amount of "tricks" compiler and programmer van do when
arguments and locals are by default static is much greater and
quite usable and imo programs coild eventually be probably faster

(i already wrote on this back then

for example i thing if you giot such wunstion

DrawText(10,10,"some");

wchich draw text beginnmh in 10 row 10th column of text console
then you eventually can call yhis function also like

DrawText(10,10,"some");
DrawText(" more");

which just skips the passing row and column and reuses its states
whch say last call set to end of previous writting

you also could have acces to them like DrawText.row

if they are stack based it seem it couldnt be probably done

its also more efective becouse you dont need that memory bandwidth to
set thiose variables if you dont need to set them or bass them back
when you need or dont need to acces them

on definition side it needs hovever some syntax to allow that
its something like

DrawText(static int row , static int column , static char* text)
{
DrawText( char* text)
{

//code here
}
}

its liek two entry points when second just omits two assigments,
some things like that can be also done in earlier or later return at the
end when separate call to the same function can calculate more return
wariabl;es or less and as return values are static you may use not all
fir
2024-11-06 23:00:00 UTC
Permalink
Post by fir
Post by Bart
Post by fir
Post by Thiago Adams
Post by fir
Post by Thiago Adams
Post by Thiago Adams
Post by fir
if c would have something that i name as named block
much more interesting options in coding in c would be
imo avaliable..
by named block i understood something like
foo {
//code here
}
whiuch resembles function , as can be placed in 'global'
(module level) space but also could be placed locally in
functions
int foo() {
a { }
b { }
}
then it could be called internally
int foo() {
a { }
b { }
int x = a()*a()*b(); //though imo () probab;ly should be optionall
}
or externally
foo.a()
those blocks probably should have acces to local variables of
parent functions or parant block so it yelds imo to conclusion
that local variables and arguments should be by default static
(those stack variables by default are bad idea imo.. its kinda optimisation
needed whan you got 4kb RAM but on bigger machines this
optimisation
is bad imo)
if so mant things can be done with this blocks probably, im not exactly
sure what exactly
ona assembly label blocks by defauld probably be done by
//...
ret
so then can be reused though some version to call it in place
of definitions could be also avaliable imo (something like
a{}() in a sense but better looking (this looks to bad)
overally those named block should be also united with function
so they become the same if use on them the functionality of
passing arguments and returning variables
foo {
a {}
int x, y = a(1,2)
}
though i maybe not sure how to add this mechanism
possibly som,ething liek this (until something better could be found)
a
{
in int c;
in int d;
out int x = c+d;
out int y = c-d;
}
or
a( int c, int d)
{
out int x = c+d;
out int y = c-d;
}
as all c d x y are static you may call a() without any or
with any set int x, y = a(1) int x = a(1,2) and compiler
would generate the assigments (how to call it on assembly level us
wuite clear, not fully clear is what syntax in language to use
this concept is yet not fully build yet but what i descrbed her i
guess is okay
Names loops (only loops) were proposed to C2Y.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
Sorry I thought your motivation was exit blocks.
I am not sure what is your motivation now, maybe lambdas? local
functions? long jump?
local jumps?
as to lambdas /closures im not sure as i never learned that concepts
(seem wierd and uglt) but maybe
as if you have blocks you could eventually pass blocks to functions
a {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p();
}
foo(10,a);
its different than pointers as possibly block could have acces to
parent variables..but that would need to be rethinked as it generate
problems (like you eventually cant compile block a above as i is just
a name so this is more liek piece of text not a real code here
eventualy some coud do
a(int i) {printf("\n %d", i)}
void foo(int n, block p)
{
for(int i=0; i<n; i++) p(i);
}
foo(10,a);
This is one of the lambda motivations.
maybe , but thsi is just a kinda detail here, as it is not so much
difference than passing pointer though it is a difference
(liek when you pass pointer code takes pointer and here if you pass blck
it acan be simpli compiled in in compile time (and thus it is possible
it can have acces to its all parent fuunction variables).. or may be
called in this "lambda " way as far as i remember that
repeat(10, {printf("zzz")} ); //when reepat is a functin that takes block
but as i said probbaly those blocks could be used for some more things
Some of this stuff, like local functions, is in gnu C.
Most other complex stuff, passing lamda functions, you will find in C++.
But unless it is already in gnu, or has been added to C23 (which may
take a decade to become common), C is not going to acquire any random
proposals that you make in threads like this.
At best you might modify one implementation to try out an idea.
I'm not really into either, but I have tried anonymous functions
(without closures) in my scripting language. Your example looks like
proc myrepeat(n, body) =
to n do
body()
end
end
proc main =
myrepeat(10, {printf("zzz")})
end
The lack of closures means the anonymous function inside {...} can't
access any stack-based names outside which are part of the enclosing
function.
normally this {printf("zzz")} cant acces not opnly stack based but any
local variables imo... (by 'normally' i mean without breaking some
present default rules.. i mean it in fact aces any like
foo({printf("zzz%d%d%d",a,b,c)}); but it just mean it more work like c++
template which "lives" only before compilation - as here a,b,c are just
texts which can be resolved at compile time to different things
- and this is not neccesart the thing im thinking about here (generally
i prefer the constructs that live after compilation, but those
eventually also could be considered
thoce stack based variables and arguments are bad for other reasons..
generally the amount of "tricks" compiler and programmer van do when
arguments and locals are by default static is much greater and
quite usable and imo programs coild eventually be probably faster
(i already wrote on this back then
for example i thing if you giot such wunstion
DrawText(10,10,"some");
wchich draw text beginnmh in 10 row 10th column of text console
then you eventually can call yhis function also like
DrawText(10,10,"some");
DrawText(" more");
which just skips the passing row and column and reuses its states
whch say last call set to end of previous writting
you also could have acces to them like DrawText.row
if they are stack based it seem it couldnt be probably done
its also more efective becouse you dont need that memory bandwidth to
set thiose variables if you dont need to set them or bass them back
when you need or dont need to acces them
on definition side it needs hovever some syntax to allow that
its something like
DrawText(static int row , static int column , static char* text)
{
DrawText( char* text)
{
//code here
}
}
its liek two entry points when second just omits two assigments,
some things like that can be also done in earlier or later return at the
end when separate call to the same function can calculate more return
wariabl;es or less and as return values are static you may use not all
generally i think about something like

mul(int x, int y)
{
static int low;
//compute x*y and if it fits in int low, return

static int high;
//if it also has high part compute high and return
}


in classic way you would need to fill and return both i guess
Bonita Montero
2024-11-07 10:41:36 UTC
Permalink
Post by fir
a {}
b{ }
c{}
int x = a*b+c;
where a,b,c are blocks of code (though here it would probably mean "run
a" get value and mul by "run b" take value , tun c and add
Use C++ and lambdas.
fir
2024-11-07 15:55:05 UTC
Permalink
Post by Bonita Montero
Post by fir
a {}
b{ }
c{}
int x = a*b+c;
where a,b,c are blocks of code (though here it would probably mean
"run a" get value and mul by "run b" take value , tun c and add
Use C++ and lambdas.
c++ has so many structural errors it makes it sh*t
(overaly all c++ is structural errors .. prbably one and only
thing interesting in c++ is operator overloading but it also is badly
done ofc)
Bonita Montero
2024-11-07 16:02:46 UTC
Permalink
Post by fir
c++ has so many structural errors it makes it sh*t
(overaly all c++ is structural errors .. prbably one and only
thing interesting in c++ is operator overloading but it also
is badly done ofc)
What do you consider as a "structural error" with C++ ?
fir
2024-11-07 17:01:26 UTC
Permalink
Post by Bonita Montero
Post by fir
c++ has so many structural errors it makes it sh*t
(overaly all c++ is structural errors .. prbably one and only
thing interesting in c++ is operator overloading but it also
is badly done ofc)
What do you consider as a "structural error" with C++ ?
many things there are simply idiotic

liek for exampe concept of suntypes and sueprtypes

when for example you got some entity that

some {
sing(); swim(); fly(); }

the subtypes are things that
1{sing(); }
2 { swim();
3 { fly();}
4 {sing(); swim(); }
5 { swim(), fly()} ;
6 { sing(); fly();}

and supertype is {
sing(); swim(); fly(); + do more}

not that idiotism of c++

also oop is hevily idiotoc ehen in normal languege you
can use and connect entities (just by putting them in visibility)
without all that idiotic pointers

thsi i call syructural errors becouse you can do things in normal
structurally correct way in c++ this is total idiotism in that place
Bonita Montero
2024-11-07 17:19:27 UTC
Permalink
Post by fir
the subtypes are things that
1{sing(); }
2 { swim();
3 { fly();}
4 {sing(); swim(); }
5 { swim(), fly()} ;
6 { sing(); fly();}
With that you could use three interfaces (classes with only pure
virtual functions) and derive them as needed. That's still OOP.
OOP is useful and a standard.
fir
2024-11-07 17:47:42 UTC
Permalink
Post by Bonita Montero
the subtypes are things that 1{sing(); } 2 { swim(); 3 { fly();} 4
{sing(); swim(); } 5 { swim(), fly()} ; 6 { sing(); fly();}
With that you could use three interfaces (classes with only pure
virtual functions) and derive them as needed. That's still OOP. OOP
is useful and a standard.
i dont remember i learned a c++ a bit in about year 2001 or so (i dont
even remember) and then droipped the learning noticing how crap it is

i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things


same with those builtin c++ spaghetti with new objest and
pointers... this c++ OOP is indeed just a monster sphagetti

all those pointers ale nonsense.. the entities with functions are okay
but visibility by pointers is deeply idiotic if yu get some entity you
need to use simply add them like

Sccreen screen1, screen2;
Ship ship[100];

then just call its methods and more... no idiotic sphagetti
fir
2024-11-07 17:54:32 UTC
Permalink
Post by fir
Post by Bonita Montero
the subtypes are things that 1{sing(); } 2 { swim(); 3 { fly();} 4
{sing(); swim(); } 5 { swim(), fly()} ; 6 { sing(); fly();}
With that you could use three interfaces (classes with only pure
virtual functions) and derive them as needed. That's still OOP. OOP
is useful and a standard.
i dont remember i learned a c++ a bit in about year 2001 or so (i dont
even remember) and then droipped the learning noticing how crap it is
i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things
same with those builtin c++ spaghetti with new objest and
pointers... this c++ OOP is indeed just a monster sphagetti
i remember a movei die herd 2 adair and then a 'simon' says imo
with memoprable voice (fort knox) "its for tourists!", close woice i
would say: "c++? Its for idiots!" ;c
Post by fir
all those pointers ale nonsense.. the entities with functions are okay
but visibility by pointers is deeply idiotic if yu get some entity you
need to use simply add them like
Sccreen screen1, screen2;
Ship ship[100];
then just call its methods and more... no idiotic sphagetti
Bonita Montero
2024-11-07 17:58:13 UTC
Permalink
Post by fir
i dont remember i learned a c++ a bit in about year 2001 or so (i dont
even remember) and then droipped the learning noticing how crap it is
I think you declare a lot of things you don't understand as crap.
Post by fir
i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things
Inheritance is not used often, mostly with large class libraries,
but when it is used it makes sense.
Post by fir
same with those builtin c++ spaghetti with new objest and
pointers... this c++ OOP is indeed just a monster sphagetti
The OOP-rules are almost the same as in Java.
fir
2024-11-07 18:09:18 UTC
Permalink
Post by Bonita Montero
Post by fir
i dont remember i learned a c++ a bit in about year 2001 or so (i dont
even remember) and then droipped the learning noticing how crap it is
I think you declare a lot of things you don't understand as crap.
Post by fir
i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things
Inheritance is not used often, mostly with large class libraries,
but when it is used it makes sense.
Post by fir
same with those builtin c++ spaghetti with new objest and
pointers... this c++ OOP is indeed just a monster sphagetti
The OOP-rules are almost the same as in Java.
java is also terreible sphagetti crap if course (but at least hava was
not offending c as c++ adding sphagetti crap to c)
Bonita Montero
2024-11-07 18:19:07 UTC
Permalink
Post by fir
java is also terreible sphagetti crap if course (but at least hava was
not offending c as c++ adding sphagetti crap to c)
Seems you're overburdened with everything.
Java is the number one language for business applications for good
reason. The language is moderately powerful (compared to C#), easy
to learn and there are high-quality class libraries for every imagi-
nable use case for business applications.
fir
2024-11-07 20:37:48 UTC
Permalink
Post by Bonita Montero
Post by fir
java is also terreible sphagetti crap if course (but at least hava was
not offending c as c++ adding sphagetti crap to c)
Seems you're overburdened with everything.
Java is the number one language for business applications for good
reason. The language is moderately powerful (compared to C#), easy
to learn and there are high-quality class libraries for every imagi-
nable use case for business applications.
so what ? you think milions of people dont do stupid things?
they do all the time.. but okay i dont want to talko about this, you
asked a question
Bonita Montero
2024-11-08 10:21:48 UTC
Permalink
Post by fir
Post by Bonita Montero
Post by fir
java is also terreible sphagetti crap if course (but at least hava was
not offending c as c++ adding sphagetti crap to c)
Seems you're overburdened with everything.
Java is the number one language for business applications for good
reason. The language is moderately powerful (compared to C#), easy
to learn and there are high-quality class libraries for every imagi-
nable use case for business applications.
so what ? you think milions of people dont do stupid things?
Should they write business code in C and have tousands of buffer overflows ?
Post by fir
they do all the time.. but okay i dont want to talko about this, you
asked a question
fir
2024-11-08 15:58:08 UTC
Permalink
Post by Bonita Montero
Post by fir
Post by Bonita Montero
Post by fir
java is also terreible sphagetti crap if course (but at least hava was
not offending c as c++ adding sphagetti crap to c)
Seems you're overburdened with everything.
Java is the number one language for business applications for good
reason. The language is moderately powerful (compared to C#), easy
to learn and there are high-quality class libraries for every imagi-
nable use case for business applications.
so what ? you think milions of people dont do stupid things?
Should they write business code in C and have tousands of buffer overflows ?
possibly if you woild write it - if you think writing on c is buffer
overflow for you
Post by Bonita Montero
Post by fir
they do all the time.. but okay i dont want to talko about this, you
asked a question
Bonita Montero
2024-11-08 16:45:35 UTC
Permalink
Post by fir
possibly if you woild write it - if you think writing on c is buffer
overflow for you
C is not suitable for business applications. With that you don't need
that much control over technical details and half the performacne is
sufficient. In C you'd write ten times the code and the code is much
more error-prone.
fir
2024-11-08 17:55:32 UTC
Permalink
Post by Bonita Montero
Post by fir
possibly if you woild write it - if you think writing on c is buffer
overflow for you
C is not suitable for business applications. With that you don't need
that much control over technical details and half the performacne is
sufficient. In C you'd write ten times the code and the code is much
more error-prone.
well first of all i was not saying c is suitable for business aplication
i dont know
it is just pssible that companies can only hire idiots and idiots may
noy be good in c etc

what i was sayin that c++ has terroble structural errors

(yet to say big prgrams like windows linux wa swritten in c so that is
kinda proof etc, but i dont want to talk this kind of idiotic
konversatiion when yoy belive something and will repeat it to me
on and on as usual...

in fact youre not c coder on c group and you share you opinions not
javing experience in c coding against people who can code in c and know
how it is going)
Bonita Montero
2024-11-08 18:07:00 UTC
Permalink
Post by fir
what i was sayin that c++ has terroble structural errors
I asked you what are the errors and you've shown that you
didn't understand the language.
fir
2024-11-08 22:18:33 UTC
Permalink
Post by Bonita Montero
Post by fir
what i was sayin that c++ has terroble structural errors
I asked you what are the errors and you've shown that you
didn't understand the language.
i must throw you out a group of people worth talking..youere like dick
hodgin, maniacal jesus belivver who fortunatelly as i guiuess finaly
gone to hell
Bonita Montero
2024-11-09 13:31:30 UTC
Permalink
Post by fir
Post by Bonita Montero
Post by fir
what i was sayin that c++ has terroble structural errors
I asked you what are the errors and you've shown that you
didn't understand the language.
i must throw you out a group of people worth talking..youere like dick
hodgin, maniacal jesus belivver who fortunatelly as i guiuess finaly
gone to hell
And you're overburdened with everything beyond C.
Janis Papanagnou
2024-11-10 08:34:23 UTC
Permalink
Post by Bonita Montero
Post by fir
[...]
I think you declare a lot of things you don't understand as crap.
Post by fir
i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things
(You haven't shown in your posts in any way that you'd have
understood even the most "fundamental things" [of OO]. That's
why I'm somewhat irritated by your heated relentless comments.)

Did the code samples you inspected (and that obviously repelled
you) have maybe been written by the "wrong [unknowing] people"?

Since you may not have understood the advantages of OO concepts,
have you taken some effort to try to understand it?

I started OO with Simula 67 at a time where the term "OO" wasn't
widely used, let alone hyped - I think it wasn't even coined at
these days but I'm not sure about it. But the advantages of OO
programming was immediately obvious to me. - I think it needs
some affiliation and openness. Not being spoiled exclusively by
other programming principles might help as well.
Post by Bonita Montero
Inheritance is not used often, mostly with large class libraries,
but when it is used it makes sense.
Where do you get that impression from that it's not used often?
Or "mostly" with large class libraries? - I certainly made other
observations and had a very different experience.

Whenever I'm operating in an OO language context I'm using its
concepts. Even simple things can be organized advantageously
with OO language concepts, inheritance and polymorphism (based
on inheritance). If you don't make use of its basic concept you
can as well abandon it; for modularity, information hiding, or
abstraction there's other ([supposedly] "simpler") languages.
Post by Bonita Montero
[...]
Post by fir
[...]
Janis
fir
2024-11-13 20:39:15 UTC
Permalink
Post by Janis Papanagnou
Post by Bonita Montero
Post by fir
[...]
I think you declare a lot of things you don't understand as crap.
Post by fir
i remember tose inheritance herarhies buit being deeply idiotic and
based on misunderstanding of fundamental things
(You haven't shown in your posts in any way that you'd have
understood even the most "fundamental things" [of OO]. That's
why I'm somewhat irritated by your heated relentless comments.)
well i told about

1) "sphagetti monster" which is inside c++ or part of c++
(this monster is made by pointers of "new" objects and the
sphagetti of its connection - where its all idiotic as normally
you simply place entities [[liek structures in c but also may have
'member functions' thise member functions are okay]] and the antities
see themselves - no idiotic sphagetti

2) the idiotic not understanding what subtype is and what super-type is

(subtyope is any combination of fields of given type, or at least any
that makes sense in given program) ...supertype is in turn extensuion of
given type by new fields or functions

What i say here comes from unserstanding this ...so who is not
understanding that? its not me

(ofc its not quite popular knowledge as i am the oryginal author of
this remarks on those structural errors, it not comes from reading in
net on this but from my ovn (and many) deeper insights on this
Post by Janis Papanagnou
Did the code samples you inspected (and that obviously repelled
you) have maybe been written by the "wrong [unknowing] people"?
Since you may not have understood the advantages of OO concepts,
have you taken some effort to try to understand it?
I started OO with Simula 67 at a time where the term "OO" wasn't
widely used, let alone hyped - I think it wasn't even coined at
these days but I'm not sure about it. But the advantages of OO
programming was immediately obvious to me. - I think it needs
some affiliation and openness. Not being spoiled exclusively by
other programming principles might help as well.
Post by Bonita Montero
Inheritance is not used often, mostly with large class libraries,
but when it is used it makes sense.
Where do you get that impression from that it's not used often?
Or "mostly" with large class libraries? - I certainly made other
observations and had a very different experience.
Whenever I'm operating in an OO language context I'm using its
concepts. Even simple things can be organized advantageously
with OO language concepts, inheritance and polymorphism (based
on inheritance). If you don't make use of its basic concept you
can as well abandon it; for modularity, information hiding, or
abstraction there's other ([supposedly] "simpler") languages.
Post by Bonita Montero
[...]
Post by fir
[...]
Janis
fir
2024-11-07 16:30:31 UTC
Permalink
Post by fir
Post by Bonita Montero
Post by fir
a {}
b{ }
c{}
int x = a*b+c;
where a,b,c are blocks of code (though here it would probably mean
"run a" get value and mul by "run b" take value , tun c and add
Use C++ and lambdas.
c++ has so many structural errors it makes it sh*t
(overaly all c++ is structural errors .. prbably one and only
thing interesting in c++ is operator overloading but it also is badly
done ofc)
besides you could do more than this lambda does , i guess
(i dont quite remember what this lambda is)

like some can define operators on this blocks for more than arithmetic
on return values

like this "inject " a<-b

a is called and it cals b from inside

b {beep();}

a(block f) {
for(int i=0; i<10; i++) f()
}

or something more complex in this spirit (i dont know what hoveve)

maybe also thiose blocks simply could be used to allow code be shorter,
i dont know
fir
2024-11-12 17:47:46 UTC
Permalink
test
Loading...