Re: on named blocks concept

Liste des GroupesRevenir à cl c  
Sujet : Re: on named blocks concept
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 06. Nov 2024, 21:24:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vggjag$28gt1$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 06/11/2024 16:46, fir wrote:
Thiago Adams wrote:
On 06/11/2024 15:46, Thiago Adams wrote:
On 06/11/2024 13:04, fir wrote:
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
>
>
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.

Date Sujet#  Auteur
6 Nov 24 * on named blocks concept31fir
6 Nov 24 `* Re: on named blocks concept30Thiago Adams
6 Nov 24  `* Re: on named blocks concept29Thiago Adams
6 Nov 24   +- Re: on named blocks concept1fir
6 Nov 24   `* Re: on named blocks concept27fir
6 Nov 24    +* Re: on named blocks concept5Thiago Adams
6 Nov 24    i`* Re: on named blocks concept4fir
6 Nov 24    i `* Re: on named blocks concept3Bart
7 Nov 24    i  `* Re: on named blocks concept2fir
7 Nov 24    i   `- Re: on named blocks concept1fir
7 Nov 24    `* Re: on named blocks concept21Bonita Montero
7 Nov 24     `* Re: on named blocks concept20fir
7 Nov 24      +* Re: on named blocks concept18Bonita Montero
7 Nov 24      i`* Re: on named blocks concept17fir
7 Nov 24      i `* Re: on named blocks concept16Bonita Montero
7 Nov 24      i  `* Re: on named blocks concept15fir
7 Nov 24      i   +- Re: on named blocks concept1fir
7 Nov 24      i   `* Re: on named blocks concept13Bonita Montero
7 Nov 24      i    +* Re: on named blocks concept10fir
7 Nov 24      i    i`* Re: on named blocks concept9Bonita Montero
7 Nov 24      i    i `* Re: on named blocks concept8fir
8 Nov 24      i    i  `* Re: on named blocks concept7Bonita Montero
8 Nov 24      i    i   `* Re: on named blocks concept6fir
8 Nov 24      i    i    `* Re: on named blocks concept5Bonita Montero
8 Nov 24      i    i     `* Re: on named blocks concept4fir
8 Nov 24      i    i      `* Re: on named blocks concept3Bonita Montero
9 Nov 24      i    i       `* Re: on named blocks concept2fir
9 Nov 24      i    i        `- Re: on named blocks concept1Bonita Montero
10 Nov 24      i    `* Re: on named blocks concept2Janis Papanagnou
13 Nov 24      i     `- Re: on named blocks concept1fir
7 Nov 24      `- Re: on named blocks concept1fir

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal