Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.c > #391451

Re: Bart's Language

From Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups comp.lang.c
Subject Re: Bart's Language
Date 2025-03-20 23:45 +0000
Organization A noiseless patient Spider
Message-ID <20250320163436.941@kylheku.com> (permalink)
References (1 earlier) <vrbo88$1j3e0$1@paganini.bofh.team> <vrbtve$2irc9$1@dont-email.me> <vrc2d5$1jjrf$1@paganini.bofh.team> <vrcri2$3doia$1@dont-email.me> <vri5c8$26v8m$1@paganini.bofh.team>

Show all headers | View raw


On 2025-03-20, Waldek Hebisch <antispam@fricas.org> wrote:
> 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.

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:

1> (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)

If we use the regular cons function, rather than the
lcons lazy cons macro operator:

2> (mlet ((a (cons 1 b))
          (b (cons 0 a)))
    (take 20 a))
** expr-1:1: force: recursion forcing delayed form (cons 1 b) (expr-1:1)

When there isn't circularity, the expressions can be in
any order; the lazy machinery will force the evaluation
of everything in the correct order:

2> (mlet ((x (+ y 3))
          (z (+ x 1))
          (y 4))
     (+ z 4))
12

First y gets 4, so (+ y 3) can initialize x to 7,
after which z can take (+ x 1) to get 8. Then
the body evaluates (+ z 4) to 12.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Bart's Language bart <bc@freeuk.com> - 2025-03-17 23:51 +0000
  Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-18 12:17 +0000
    Re: Bart's Language bart <bc@freeuk.com> - 2025-03-18 13:54 +0000
      Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-18 15:10 +0000
        Re: Bart's Language bart <bc@freeuk.com> - 2025-03-18 15:45 +0000
          Re: Bart's Language David Brown <david.brown@hesbynett.no> - 2025-03-18 17:31 +0100
            int a = a (Was: Bart's Language) gazelle@shell.xmission.com (Kenny McCormack) - 2025-03-18 18:04 +0000
              Re: int a = a (Was: Bart's Language) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-18 19:36 +0100
                Re: int a = a (Was: Bart's Language) Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-18 19:11 +0000
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-19 15:56 +0100
                Re: int a = a (Was: Bart's Language) scott@slp53.sl.home (Scott Lurndal) - 2025-03-19 16:38 +0000
                Re: int a = a (Was: Bart's Language) "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-03-19 14:29 -0700
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-20 09:39 +0100
                Re: int a = a (Was: Bart's Language) bart <bc@freeuk.com> - 2025-03-20 11:59 +0000
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-20 15:46 +0100
                Re: int a = a (Was: Bart's Language) wij <wyniijj5@gmail.com> - 2025-03-20 23:13 +0800
                Re: int a = a (Was: Bart's Language) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 02:02 -0700
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-20 15:57 +0100
                Re: int a = a (Was: Bart's Language) Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-19 17:07 +0000
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-19 13:34 -0700
                Re: int a = a Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 02:54 -0700
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-20 03:20 -0700
                Re: int a = a David Brown <david.brown@hesbynett.no> - 2025-03-20 16:22 +0100
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-20 12:46 -0700
                Re: int a = a David Brown <david.brown@hesbynett.no> - 2025-03-21 10:44 +0100
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-21 12:23 -0700
                Re: int a = a David Brown <david.brown@hesbynett.no> - 2025-03-21 21:46 +0100
                Re: int a = a Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-22 13:59 -0700
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-22 15:37 -0700
                Re: int a = a David Brown <david.brown@hesbynett.no> - 2025-03-20 15:42 +0100
              Re: int a = a (Was: Bart's Language) scott@slp53.sl.home (Scott Lurndal) - 2025-03-18 19:37 +0000
              Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-18 20:51 +0100
                Re: int a = a (Was: Bart's Language) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-18 23:27 +0100
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-19 11:40 +0100
              Re: int a = a (Was: Bart's Language) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-18 23:52 -0700
                Re: int a = a Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-19 01:55 -0700
                Re: int a = a (Was: Bart's Language) David Brown <david.brown@hesbynett.no> - 2025-03-19 11:43 +0100
                Re: int a = a (Was: Bart's Language) Rosario19 <Ros@invalid.invalid> - 2025-03-19 13:23 +0100
                Re: int a = a (Was: Bart's Language) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 01:32 -0700
          Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-20 22:55 +0000
            Re: Bart's Language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-20 16:22 -0700
              Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-22 14:37 +0000
                Re: Bart's Language James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-22 11:41 -0400
                Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-22 16:52 +0000
                Re: Bart's Language James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-22 20:12 -0400
                By definition... (Was: Bart's Language) gazelle@shell.xmission.com (Kenny McCormack) - 2025-03-23 17:20 +0000
        Re: Bart's Language bart <bc@freeuk.com> - 2025-03-18 22:19 +0000
          Re: Bart's Language antispam@fricas.org (Waldek Hebisch) - 2025-03-20 22:38 +0000
            Re: Bart's Language Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-20 23:45 +0000
              Re: Bart's Language bart <bc@freeuk.com> - 2025-03-21 00:56 +0000
                Re: Bart's Language Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-21 17:47 +0000
                Re: Bart's Language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-22 07:12 -0700
            Re: Bart's Language bart <bc@freeuk.com> - 2025-03-21 00:33 +0000

csiph-web