Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The world is no nursery. -- Sigmund Freud


devel / comp.lang.forth / Tail call optimization (was: .Re: Lisp benefits ...)

SubjectAuthor
* .Re: Lisp benefits against other functional programming languagesRobert L.
`* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
 `* Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |`- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  +* Re: .Re: Lisp benefits against other functional programming languagesJali Heinonen
  |+- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  |`* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
  | `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
  |  `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
  |   +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |   |`- Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
  |   +- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
  |   `* Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  |    `* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |     `* Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  |      `* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |       `- Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  `* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
   +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
   |`- Re: .Re: Lisp benefits against other functional programming languagesMarcel Hendrix
   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
    `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
     `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      +* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      |+* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||+- Re: .Re: Lisp benefits against other functional programming languagesdxforth
      ||`* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      || `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||  `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   +* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |`* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   | +- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   | `* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
      ||   |  `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   |   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |    `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |     `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |      `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |       `* Re: .Re: Lisp benefits against other functional programming languagesBrian Fox
      ||   |        `* Tail call optimization (was: .Re: Lisp benefits ...)Anton Ertl
      ||   |         `* Re: Tail call optimization (was: .Re: Lisp benefits ...)Hans Bezemer
      ||   |          `* Re: Tail call optimization (was: .Re: Lisp benefits ...)Anton Ertl
      ||   |           `- Re: Tail call optimization (was: .Re: Lisp benefits ...)Hans Bezemer
      ||   +* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |`- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   `- Re: .Re: Lisp benefits against other functional programming languagesMarcel Hendrix
      |`* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      | +- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      | +- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      | `* Re: .Re: Lisp benefits against other functional programming languagesrussell mcmanus
      |  +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
      |  |`- Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |  `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      |    `- Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      +* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |`- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      `- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman

Pages:123
Re: .Re: Lisp benefits against other functional programming languages

<60f4a476-2ad5-47af-a524-1d11ff553faan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17315&group=comp.lang.forth#17315

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:508:b0:2e1:deae:22bd with SMTP id l8-20020a05622a050800b002e1deae22bdmr3422361qtx.597.1647522623021;
Thu, 17 Mar 2022 06:10:23 -0700 (PDT)
X-Received: by 2002:a05:6214:5007:b0:436:5f36:1819 with SMTP id
jo7-20020a056214500700b004365f361819mr3251620qvb.29.1647522622736; Thu, 17
Mar 2022 06:10:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 17 Mar 2022 06:10:22 -0700 (PDT)
In-Reply-To: <dc8b2b49-8015-4a17-b7c6-1b10632804c9n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at> <dc8b2b49-8015-4a17-b7c6-1b10632804c9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <60f4a476-2ad5-47af-a524-1d11ff553faan@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Thu, 17 Mar 2022 13:10:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: Hans Bezemer - Thu, 17 Mar 2022 13:10 UTC

On Thursday, March 17, 2022 at 10:07:00 AM UTC+1, minf...@arcor.de wrote:
> A practical application example:
> Alarm logs in realtime control systems are one area where sorting is
> required for output on display, reports, data extraction and analysis.
> When this could touch time-critical functions, sorting is often supported by
> background indexing while new alarms are added to the alarm tables.
> IOW fancy sorting algorithms or data movement are not necessary here.

Well, I guess that's the point here - different problems require different techniques.
I often find myself in situations where I got A, but I need an association with B.

Now I see myself people crying to me "trees, associative arrays, hash tables" - but very,
very often these things are fixed. They MIGHT have the occasional maintenance for one
reason or another, but in essence: fixed.

Now it REALLY depends on the problem. Is it consulted very often with large amounts of
data or just once at startup? Since the "lookup" routine doesn't change it would be weird to
introduce a lot of overhead (bloat if you will) - especially if other fast techniques are available.

If speed is not an issue, I do a linear search O(n). I got a lib for that, so that's a one liner. If speed
is an issue, then I do a binary search O(log n). If I can enumerate the data (offset may be required)
I do a direct lookup O(1).

Strings may be sped up by doing a hash. Sometimes I use a mix of hashing and binary search to
keep the required amount of space down.

Anyway, my life revolves around tables and structures. That's why.. ;-)

Hans Bezemer

Re: .Re: Lisp benefits against other functional programming languages

<877d8s9hgv.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17320&group=comp.lang.forth#17320

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 18:28:48 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <877d8s9hgv.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<2022Mar17.082842@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="715502d6767f816b066c4422c8c0e06a";
logging-data="31065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dOsD8pgTeScROSypwYKqL"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:3Fsqi07R0y/NpDK77hmJwHhp+jA=
sha1:SJ05E5W4OcTsco1asgf9S7J6/Z4=
 by: Paul Rubin - Fri, 18 Mar 2022 01:28 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> What are the use cases? I have not found a serious use for search
> trees in my programming, much less balanced search trees.

They have deterministic access time unlike hash tables, and it is easy
to traverse them in key order. Also, if you are willing to mutate them,
you can do fast updates and deletions by occasionally splitting nodes.
Databases do this with B-trees all the time.

Also, in the case where you don't need to update, they can use more
compact storage than hash tables do (Patricia trees). Search engines
typically store indexes that way. You have a big index, then one or
more generations of smaller indexes for updates, and now and then you do
a big merge to get a new big index.

Re: .Re: Lisp benefits against other functional programming languages

<8735jg9hc8.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17321&group=comp.lang.forth#17321

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 18:31:35 -0700
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <8735jg9hc8.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com>
<2022Mar17.085213@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="715502d6767f816b066c4422c8c0e06a";
logging-data="31065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yR8k2Va6pSsfIw7p2yd1m"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:RC97NRgiOf68XdPEbwHkFtWPrss=
sha1:nmFW1nypsiq50nOXtY9BUSJvxWA=
 by: Paul Rubin - Fri, 18 Mar 2022 01:31 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> The typical approach on memory-starved systems was static arrays

I don't know about true memory starvation (microcontroller with a few
hundred bytes of ram) but I remember working on a PDP-11 text editor.
Its buffer representation was linked lists of up to something like 64
bytes, so insertions and deletions operated on those list nodes and
could split and merge them.

Re: .Re: Lisp benefits against other functional programming languages

<87v8wc8288.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17322&group=comp.lang.forth#17322

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 18:43:19 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <87v8wc8288.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="715502d6767f816b066c4422c8c0e06a";
logging-data="31065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MC6y4L9vFrShwjOhRhSzy"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:02v7a8E9z1Mq/oVTUJ7l2Y0X6JA=
sha1:2fFsXnMmMV2RKehiLaVo49J7JQc=
 by: Paul Rubin - Fri, 18 Mar 2022 01:43 UTC

Ron AARON <clf@8th-dev.com> writes:
> I'm unsure what you mean, then, by 'mutation'...

Mutation means modifying the contents of computer memory. Like the
memory contents are written on graph paper in pencil, and you can update
a cell by erasing the old contents and writing something new in its
place.

Functional or immutable programming is a style where you write with a
pen instead of a pencil, so you can't update or erase. You can only
write stuff in new empty squares. In reality, gc finds
no-longer-accessible old squares and recycles them into new squares, but
your program can't tell that this is happening. Instead of hash tables
you use balanced trees, instead of loops with a mutable index you use
recursion, etc. Functional languages always optimize away tail calls so
you can write recursive loops that don't overflow the stack.

SICP (mitpress.mit.edu/sicp) presents Scheme in mostly functional style,
and Haskell (learnyouahaskell.com is a good place to start) is a
"purely" (well, almost purely) functional languages.

This approach has costs, but gives various theoretical and practical
advantages for validating properties of programs. Basically certain
classes of bugs go away, just like programming without the "goto"
statement has costs but cleans up some control flow confusion.

Re: .Re: Lisp benefits against other functional programming languages

<t1156o$iu1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17325&group=comp.lang.forth#17325

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 07:26:47 +0200
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <t1156o$iu1$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 05:26:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bf7d2266759f26f88790f290c3674f22";
logging-data="19393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18m6NX1+PmgLqAJ7cj4ZvF8"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:oN33QEZqbZ7gxELv/Vb6X+qEt7w=
In-Reply-To: <87v8wc8288.fsf@nightsong.com>
Content-Language: en-US
 by: Ron AARON - Fri, 18 Mar 2022 05:26 UTC

On 18/03/2022 3:43, Paul Rubin wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> I'm unsure what you mean, then, by 'mutation'...
>
> Mutation means modifying the contents of computer memory. Like the
> memory contents are written on graph paper in pencil, and you can update
> a cell by erasing the old contents and writing something new in its
> place.

Right, that's what I had thought you meant by the term.

8th's model is that containers are mutable (arrays, maps, etc); that
eliminates excessive copying (when you just want to change one item in
an array, for instance).

This can lead to a little excitement when the programmer didn't read the
documentation, and wonders why an array embedded in a word seems to
change...

>
> Functional or immutable programming is a style where you write with a
> pen instead of a pencil, so you can't update or erase. You can only
> write stuff in new empty squares. In reality, gc finds
> no-longer-accessible old squares and recycles them into new squares, but
> your program can't tell that this is happening. Instead of hash tables
> you use balanced trees, instead of loops with a mutable index you use
> recursion, etc. Functional languages always optimize away tail calls so
> you can write recursive loops that don't overflow the stack.

Are there any (serious) languages which don't optimize tail calls by
default?

> SICP (mitpress.mit.edu/sicp) presents Scheme in mostly functional style,
> and Haskell (learnyouahaskell.com is a good place to start) is a
> "purely" (well, almost purely) functional languages.

Java, for that matter, has a lot of the immutable-data philosophy; but
it's applied inconsistently. Of course, it's not functional (in more
than one way, IMO).

>
> This approach has costs, but gives various theoretical and practical
> advantages for validating properties of programs. Basically certain
> classes of bugs go away, just like programming without the "goto"
> statement has costs but cleans up some control flow confusion.

I'll just say that the hand-wringing over 'goto' is overwrought. I don't
make a habit of using it (in C code), but sometimes it really is the
best way to do something.

Re: .Re: Lisp benefits against other functional programming languages

<87r16z94ap.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17326&group=comp.lang.forth#17326

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 23:13:18 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87r16z94ap.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="715502d6767f816b066c4422c8c0e06a";
logging-data="2498"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vKxWDoRvwyAine3M239fb"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:TC5AwF86HohdSsmOz/J/DP12vnk=
sha1:2QNS1i8aAYylEoVWWIVrmmgRJWw=
 by: Paul Rubin - Fri, 18 Mar 2022 06:13 UTC

Ron AARON <clf@8th-dev.com> writes:
> Are there any (serious) languages which don't optimize tail calls by
> default?

Forth? :)

> Java, for that matter, has a lot of the immutable-data philosophy;

No I mean it's much different: functional style generally prefers trees
or lists over arrays, for example.

Re: .Re: Lisp benefits against other functional programming languages

<t1185m$54o$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17327&group=comp.lang.forth#17327

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 08:17:26 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <t1185m$54o$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 06:17:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bf7d2266759f26f88790f290c3674f22";
logging-data="5272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Y9fgZoI1Fw0leMRS1VXAG"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:Vl3kU4KgOKGOzEZZvS7mfEMVAIU=
In-Reply-To: <87r16z94ap.fsf@nightsong.com>
Content-Language: en-US
 by: Ron AARON - Fri, 18 Mar 2022 06:17 UTC

On 18/03/2022 8:13, Paul Rubin wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> Are there any (serious) languages which don't optimize tail calls by
>> default?
>
> Forth? :)

You might be joking, but Reva and 8th both did that optimization, and
I'm pretty sure others do as well. It's almost a no-brainer.

>
>> Java, for that matter, has a lot of the immutable-data philosophy;
>
> No I mean it's much different: functional style generally prefers trees
> or lists over arrays, for example.

Well, I'll concede the point, not having a horse in the race.

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar18.084947@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17329&group=comp.lang.forth#17329

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 07:49:47 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 25
Message-ID: <2022Mar18.084947@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com> <6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com> <87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me> <87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me> <87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="dde9b1e8841056cc64c19726ef7a3663";
logging-data="20261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18R+tttvdBuSlWZ1rfY968Q"
Cancel-Lock: sha1:Bn8laRxHfoHlDVETMpRdS/R6IYw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 18 Mar 2022 07:49 UTC

Ron AARON <clf@8th-dev.com> writes:
>Are there any (serious) languages which don't optimize tail calls by
>default?

What is "by default" supposed to mean? Given that you say
"languages", the question is about guaranteeing tail-call
optimization. And looking at
<https://en.wikipedia.org/wiki/Tail_call#Language_support>, the
question becomes if there is any language that a significant
proportion of programmers take serious that guarantees tail-call
optimization. Most languages that guarantee it are niche languages
(not taken seriously by most programmers), and for the most popular
language that at least comes close to guaranteeing it (the wording is
not very enlightening), JavaScript, two out of three implementations
are listed as "rejecting" (whatever this means) this standard feature.

Interesting cases of languages that do not guarantee tail-call
optimization although I expected it are Common Lisp and F#.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<6234647a$0$702$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17333&group=comp.lang.forth#17333

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Fri, 18 Mar 2022 06:52:39 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Subject: Re: .Re: Lisp benefits against other functional programming languages
Content-Language: en-US
Newsgroups: comp.lang.forth
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com>
From: dhoffman...@gmail.com (Doug Hoffman)
In-Reply-To: <87fsnh9mds.fsf@nightsong.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 19
Message-ID: <6234647a$0$702$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: f57440c9.news.sunsite.dk
X-Trace: 1647600762 news.sunsite.dk 702 glidedog@gmail.com/68.55.82.126:49500
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Fri, 18 Mar 2022 10:52 UTC

On 3/17/22 1:30 AM, Paul Rubin wrote:

> I think resizeable arrays are more usable now than they were in the old
> days on memory starved systems. [snip] ...
>
> Lists are also natural if you program in functional style, since you
> don't have to mutate existing objects (consing is just new allocations:
> the old stuff stays the same).

Yes. Stroustrup says to use arrays instead of lists because lists use
more memory (for the link address(s)) and lists cost time because
finding the insertion/deletion point is slow due to the required linear
search.

I use arrays for most all of my list needs. Though linked lists are
useful for some things such as adding items to the end without having to
allocate memory.

-Doug

Re: .Re: Lisp benefits against other functional programming languages

<t123rs$2l8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17337&group=comp.lang.forth#17337

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 16:10:02 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <t123rs$2l8$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<2022Mar18.084947@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 14:10:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bf7d2266759f26f88790f290c3674f22";
logging-data="2728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181hWUQUJ8OimM5Prf9x1mh"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Cancel-Lock: sha1:yzPWU+z6LY/LAL7eehMv3kAbhek=
In-Reply-To: <2022Mar18.084947@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ron AARON - Fri, 18 Mar 2022 14:10 UTC

On 2022-03-18 9:49, Anton Ertl wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> Are there any (serious) languages which don't optimize tail calls by
>> default?
>
> What is "by default" supposed to mean? Given that you say
> "languages", the question is about guaranteeing tail-call
> optimization. ...

So I've always turn on some optimization with gcc and clang, and though
that the default was to do tail-call optimization. Turns out I was
wrong, and so I retract...

Re: .Re: Lisp benefits against other functional programming languages

<0ba3f222-71c6-4a4f-92fb-a0643ff55ca4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17340&group=comp.lang.forth#17340

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2943:b0:67d:5ce7:4207 with SMTP id n3-20020a05620a294300b0067d5ce74207mr6006638qkp.706.1647616869865;
Fri, 18 Mar 2022 08:21:09 -0700 (PDT)
X-Received: by 2002:ae9:e011:0:b0:67d:4c7a:c3b9 with SMTP id
m17-20020ae9e011000000b0067d4c7ac3b9mr6042469qkk.571.1647616869508; Fri, 18
Mar 2022 08:21:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 18 Mar 2022 08:21:09 -0700 (PDT)
In-Reply-To: <t1156o$iu1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=176.74.235.101; posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 176.74.235.101
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0ba3f222-71c6-4a4f-92fb-a0643ff55ca4n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Fri, 18 Mar 2022 15:21:09 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: Marcel Hendrix - Fri, 18 Mar 2022 15:21 UTC

On Friday, March 18, 2022 at 6:26:50 AM UTC+1, Ron AARON wrote:
> On 18/03/2022 3:43, Paul Rubin wrote:
[..]
> I'll just say that the hand-wringing over 'goto' is overwrought. I don't
> make a habit of using it (in C code), but sometimes it really is the
> best way to do something.

If it is good enough for Knuth, it is good enough for me.

-marcel

Re: .Re: Lisp benefits against other functional programming languages

<87mthn8d8c.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17341&group=comp.lang.forth#17341

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 08:57:55 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <87mthn8d8c.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="715502d6767f816b066c4422c8c0e06a";
logging-data="4808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iA8sWP12Xwwmbgavu6ZsM"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:gIBmq/RUIPi7Vvr5sBuD3BYgyRw=
sha1:l6rdiRswlpvbtHzHXxiUR+z+/go=
 by: Paul Rubin - Fri, 18 Mar 2022 15:57 UTC

Ron AARON <clf@8th-dev.com> writes:
> You might be joking, but Reva and 8th both did that optimization, and
> I'm pretty sure others do as well. It's almost a no-brainer.

gforth doesn't seem to:

Gforth 0.7.3, ...
: foo ( n -- 0 ) dup 0<> IF 1- recurse THEN ; ok
100 foo . 0 ok
1000 foo . 0 ok
100000 foo .
:4: Return stack overflow
100000 >>>foo<<< .

Python chooses not to, on the grounds that it makes debugging harder.

GCC and some other compilers implement it as an optimization, but the
language specs don't require it, so it doesn't entirely count. However,
I'm surprised to hear (per Anton's post) that F# doesn't require it.
Scheme, OCaml, and Haskell all require it, as there is basically no
other way to write a loop.

Give Haskell a try, it is like a mind expanding drug ;)

Re: .Re: Lisp benefits against other functional programming languages

<t12brg$7us$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17342&group=comp.lang.forth#17342

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 11:26:22 -0500
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <t12brg$7us$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 16:26:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ccda8a585b354e01da84a93132435a9b";
logging-data="8156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Qg/is1N3/q+Dg5OVtvtan"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.0
Cancel-Lock: sha1:GK5g02HJgCr22Wv43Rdz8esB+Tc=
In-Reply-To: <2022Mar17.085721@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Krishna Myneni - Fri, 18 Mar 2022 16:26 UTC

On 3/17/22 02:57, Anton Ertl wrote:
> Ron AARON <clf@8th-dev.com> writes:
>>
>>
>> On 16/03/2022 18:06, Anton Ertl wrote:
>>> What's the obsession with sorting? I have not needed a
>>> sort in Forth in the 38 years since I started using it. And IIRC not
>>> in C, either.
>>
>> Really? I've needed sorting for a variety of applications (in 8th, or
>> C/C++, or any other language -- the language is besides the point).
>
> The language is important. In most languages sorting is not needed,

> but the shell has tools such as join and uniq that require sorted
> inputs (or, in the case of many uses of uniq, are useless without
> sorting first); with hash-table-based equivalents of these tools most
> of my uses of sort in shell scripts could be eliminated, and thus most
> of my uses of sorting. Of course, in my shell usage there is still
> the following usage:
>
> Sorting is useful for human consumption, so I sometimes do it as last
> step on the output of a Forth or C program (and I have a nice shell
> tool called sort for that). But sorting is normally not useful for
> internal operations of programs; hashing is almost always better
> there.
> ...

Try writing a trapezoid integrator or Simpson's rule integrator without
using sorted (x, y) pairs, sorted on x. Algorithms for numerical
integration, differentiation, fast-Fourier and other types of transforms
are a few of the cases where sorting is essential. Sorting is not just
for user-convenient output.

--
Krishna

Re: .Re: Lisp benefits against other functional programming languages

<5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17343&group=comp.lang.forth#17343

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:e6c5:0:b0:42c:d5f:7e4c with SMTP id l5-20020a0ce6c5000000b0042c0d5f7e4cmr7452990qvn.93.1647621359972;
Fri, 18 Mar 2022 09:35:59 -0700 (PDT)
X-Received: by 2002:a05:620a:1722:b0:67d:8efe:d4e8 with SMTP id
az34-20020a05620a172200b0067d8efed4e8mr6366963qkb.327.1647621359759; Fri, 18
Mar 2022 09:35:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 18 Mar 2022 09:35:59 -0700 (PDT)
In-Reply-To: <t12brg$7us$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at> <t12brg$7us$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 18 Mar 2022 16:35:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 48
 by: minf...@arcor.de - Fri, 18 Mar 2022 16:35 UTC

Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:26:26 UTC+1:
> On 3/17/22 02:57, Anton Ertl wrote:
> > Ron AARON <c...@8th-dev.com> writes:
> >>
> >>
> >> On 16/03/2022 18:06, Anton Ertl wrote:
> >>> What's the obsession with sorting? I have not needed a
> >>> sort in Forth in the 38 years since I started using it. And IIRC not
> >>> in C, either.
> >>
> >> Really? I've needed sorting for a variety of applications (in 8th, or
> >> C/C++, or any other language -- the language is besides the point).
> >
> > The language is important. In most languages sorting is not needed,
>
>
>
> > but the shell has tools such as join and uniq that require sorted
> > inputs (or, in the case of many uses of uniq, are useless without
> > sorting first); with hash-table-based equivalents of these tools most
> > of my uses of sort in shell scripts could be eliminated, and thus most
> > of my uses of sorting. Of course, in my shell usage there is still
> > the following usage:
> >
> > Sorting is useful for human consumption, so I sometimes do it as last
> > step on the output of a Forth or C program (and I have a nice shell
> > tool called sort for that). But sorting is normally not useful for
> > internal operations of programs; hashing is almost always better
> > there.
> > ...
>
> Try writing a trapezoid integrator or Simpson's rule integrator without
> using sorted (x, y) pairs, sorted on x. Algorithms for numerical
> integration, differentiation, fast-Fourier and other types of transforms
> are a few of the cases where sorting is essential. Sorting is not just
> for user-convenient output.
>

Well, yes.. but practically you get your numeric data already sorted
eg as signal (sorted) over time. I can't remember ever having to sort
such data, only having to preprocess it (fill in gaps, Butterworth smoothing etc)

Re: .Re: Lisp benefits against other functional programming languages

<t12d1d$2en$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17344&group=comp.lang.forth#17344

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 11:46:35 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <t12d1d$2en$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at> <t12brg$7us$1@dont-email.me>
<5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 18 Mar 2022 16:46:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ccda8a585b354e01da84a93132435a9b";
logging-data="2519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mrI0Yn6sdftirwmbTGcmL"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.0
Cancel-Lock: sha1:/klUTtAU/LYLxPMCG95hd8dePa8=
In-Reply-To: <5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com>
Content-Language: en-US
 by: Krishna Myneni - Fri, 18 Mar 2022 16:46 UTC

On 3/18/22 11:35, minf...@arcor.de wrote:
> Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:26:26 UTC+1:
....
>> Try writing a trapezoid integrator or Simpson's rule integrator without
>> using sorted (x, y) pairs, sorted on x. Algorithms for numerical
>> integration, differentiation, fast-Fourier and other types of transforms
>> are a few of the cases where sorting is essential. Sorting is not just
>> for user-convenient output.
>>
>
> Well, yes.. but practically you get your numeric data already sorted
> eg as signal (sorted) over time. I can't remember ever having to sort
> such data, only having to preprocess it (fill in gaps, Butterworth smoothing etc)

Not always. It is normal in some instances to collect data for which the
independent variable (x) is not sorted, e.g. a drifting parameter which
covers the region of interest. I have collected data in this mode when
it is less noisy than controlling the independent variable, or when the
drift is slow enough to provide finer resolution in x than my minimum
control step size.

--
Krishna

Re: .Re: Lisp benefits against other functional programming languages

<ee5553ae-7c36-4193-ad3e-668f218fad49n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17346&group=comp.lang.forth#17346

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:244f:b0:67d:ccec:3eaa with SMTP id h15-20020a05620a244f00b0067dccec3eaamr6773525qkn.744.1647632375190;
Fri, 18 Mar 2022 12:39:35 -0700 (PDT)
X-Received: by 2002:a37:a310:0:b0:67d:3749:16e7 with SMTP id
m16-20020a37a310000000b0067d374916e7mr6580033qke.159.1647632375008; Fri, 18
Mar 2022 12:39:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 18 Mar 2022 12:39:34 -0700 (PDT)
In-Reply-To: <t12d1d$2en$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at> <t12brg$7us$1@dont-email.me>
<5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com> <t12d1d$2en$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ee5553ae-7c36-4193-ad3e-668f218fad49n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 18 Mar 2022 19:39:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 33
 by: minf...@arcor.de - Fri, 18 Mar 2022 19:39 UTC

Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:46:39 UTC+1:
> On 3/18/22 11:35, minf...@arcor.de wrote:
> > Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:26:26 UTC+1:
> ...
> >> Try writing a trapezoid integrator or Simpson's rule integrator without
> >> using sorted (x, y) pairs, sorted on x. Algorithms for numerical
> >> integration, differentiation, fast-Fourier and other types of transforms
> >> are a few of the cases where sorting is essential. Sorting is not just
> >> for user-convenient output.
> >>
> >
> > Well, yes.. but practically you get your numeric data already sorted
> > eg as signal (sorted) over time. I can't remember ever having to sort
> > such data, only having to preprocess it (fill in gaps, Butterworth smoothing etc)
> Not always. It is normal in some instances to collect data for which the
> independent variable (x) is not sorted, e.g. a drifting parameter which
> covers the region of interest. I have collected data in this mode when
> it is less noisy than controlling the independent variable, or when the
> drift is slow enough to provide finer resolution in x than my minimum
> control step size.
>

IIUC we call this resampling, but 100% okay, real world tasks determine
their own solution paths. Physics and related engineering software are only
mathematical models after all.

Re: .Re: Lisp benefits against other functional programming languages

<t130f2$qkt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17347&group=comp.lang.forth#17347

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Fri, 18 Mar 2022 17:18:09 -0500
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <t130f2$qkt$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at> <t12brg$7us$1@dont-email.me>
<5774841c-96b2-483d-b9c0-63c8eac1d97fn@googlegroups.com>
<t12d1d$2en$1@dont-email.me>
<ee5553ae-7c36-4193-ad3e-668f218fad49n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 18 Mar 2022 22:18:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ccda8a585b354e01da84a93132435a9b";
logging-data="27293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/A+lkelj89Pzl/zg+b3HjH"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.0
Cancel-Lock: sha1:1WCC68jeWtqvQaQzqAIjXTOTXKg=
In-Reply-To: <ee5553ae-7c36-4193-ad3e-668f218fad49n@googlegroups.com>
Content-Language: en-US
 by: Krishna Myneni - Fri, 18 Mar 2022 22:18 UTC

On 3/18/22 14:39, minf...@arcor.de wrote:
> Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:46:39 UTC+1:
>> On 3/18/22 11:35, minf...@arcor.de wrote:
>>> Krishna Myneni schrieb am Freitag, 18. März 2022 um 17:26:26 UTC+1:
>> ...
>>>> Try writing a trapezoid integrator or Simpson's rule integrator without
>>>> using sorted (x, y) pairs, sorted on x. Algorithms for numerical
>>>> integration, differentiation, fast-Fourier and other types of transforms
>>>> are a few of the cases where sorting is essential. Sorting is not just
>>>> for user-convenient output.
>>>>
>>>
>>> Well, yes.. but practically you get your numeric data already sorted
>>> eg as signal (sorted) over time. I can't remember ever having to sort
>>> such data, only having to preprocess it (fill in gaps, Butterworth smoothing etc)
>> Not always. It is normal in some instances to collect data for which the
>> independent variable (x) is not sorted, e.g. a drifting parameter which
>> covers the region of interest. I have collected data in this mode when
>> it is less noisy than controlling the independent variable, or when the
>> drift is slow enough to provide finer resolution in x than my minimum
>> control step size.
>>
>
> IIUC we call this resampling, but 100% okay, real world tasks determine
> their own solution paths. Physics and related engineering software are only
> mathematical models after all.

Here's a loadable Forth module which performs exactly the type of
sorting I'm talking about within the graphical program XYPLOT-32:

https://github.com/mynenik/XYPLOT-32/blob/master/modules/xysort.4th

It's based on single array sort from the Forth Scientific Library.

--
Krishna

Re: .Re: Lisp benefits against other functional programming languages

<7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17348&group=comp.lang.forth#17348

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:5d1:b0:2e0:70c7:1678 with SMTP id d17-20020a05622a05d100b002e070c71678mr9247136qtb.43.1647645926286;
Fri, 18 Mar 2022 16:25:26 -0700 (PDT)
X-Received: by 2002:a05:620a:2952:b0:67d:b2a3:4232 with SMTP id
n18-20020a05620a295200b0067db2a34232mr7300511qkp.56.1647645926147; Fri, 18
Mar 2022 16:25:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 18 Mar 2022 16:25:25 -0700 (PDT)
In-Reply-To: <t1185m$54o$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Fri, 18 Mar 2022 23:25:26 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Hans Bezemer - Fri, 18 Mar 2022 23:25 UTC

On Friday, March 18, 2022 at 7:17:28 AM UTC+1, Ron AARON wrote:
> On 18/03/2022 8:13, Paul Rubin wrote:
> > Ron AARON <c...@8th-dev.com> writes:
> >> Are there any (serious) languages which don't optimize tail calls by
> >> default?
> >
> > Forth? :)
> You might be joking, but Reva and 8th both did that optimization, and
> I'm pretty sure others do as well. It's almost a no-brainer.
Tail call optimization was the start of 4tH's peephole optimizer,
So it has been part of that one for at least a decade..

Hans Bezemer

Re: .Re: Lisp benefits against other functional programming languages

<t151c1$uno$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17360&group=comp.lang.forth#17360

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Sat, 19 Mar 2022 18:45:52 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <t151c1$uno$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me>
<7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 16:45:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9a9f96edda8c8a3bce24f12cffcaac5b";
logging-data="31480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18edQbpIBKo8chOp/iUTRFa"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:fGY0TU2eyL8wlLvptAQxP21lm9Q=
In-Reply-To: <7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>
Content-Language: en-US
 by: Ron AARON - Sat, 19 Mar 2022 16:45 UTC

On 19/03/2022 1:25, Hans Bezemer wrote:
> On Friday, March 18, 2022 at 7:17:28 AM UTC+1, Ron AARON wrote:
>> On 18/03/2022 8:13, Paul Rubin wrote:
>>> Ron AARON <c...@8th-dev.com> writes:
>>>> Are there any (serious) languages which don't optimize tail calls by
>>>> default?
>>>
>>> Forth? :)
>> You might be joking, but Reva and 8th both did that optimization, and
>> I'm pretty sure others do as well. It's almost a no-brainer.
> Tail call optimization was the start of 4tH's peephole optimizer,
> So it has been part of that one for at least a decade..

To be quite honest, I'm not sure why it wouldn't always be turned-on. It
really is a 'no-brainer'. But... well, apparently people disagree.

Re: .Re: Lisp benefits against other functional programming languages

<878rt56cdk.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17362&group=comp.lang.forth#17362

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Sat, 19 Mar 2022 11:11:35 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <878rt56cdk.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me>
<7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>
<t151c1$uno$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="cb044118230895ec1b29f5febfa0a020";
logging-data="8474"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/tgEkRrt8DhwJqJaBzrBm"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:kID2Vyi74mmZtRn2oKM6QByJC8s=
sha1:ZGPWY/eL4hg9yOMYtaHG+XqKWgQ=
 by: Paul Rubin - Sat, 19 Mar 2022 18:11 UTC

Ron AARON <clf@8th-dev.com> writes:
> To be quite honest, I'm not sure why it wouldn't always be
> turned-on. It really is a 'no-brainer'. But... well, apparently people
> disagree.

In imperative languages like Forth and descendants, it's usually easy
enough to write tail recursive functions as loops. If you instead write
them with tail recursion, you're relying on an optimization to be
present in the compiler even though the language spec doesn't require
it. So your program becomes less portable without a very compelling
reason. This is even true for Common Lisp, where most serious
implementations do implement TRO, and recursion comes naturally to
users.

Some languages and dialects such as Scheme require TRO in the language
spec, and favor a style that uses TR instead of loops, so using TR in
your programs is then a good thing, or in some cases (Haskell) a
necessary thing.

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar19.195204@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17363&group=comp.lang.forth#17363

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Sat, 19 Mar 2022 18:52:04 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 22
Message-ID: <2022Mar19.195204@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me> <87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me> <87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me> <87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me> <7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com> <t151c1$uno$1@dont-email.me> <878rt56cdk.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="8a234e4179e22fb314fec1c4693275b5";
logging-data="24553"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18et5j0HfLgeVrnBngQNeO/"
Cancel-Lock: sha1:qR2FU7j1bHQkkaqTdrxmENcRpA4=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 19 Mar 2022 18:52 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>In imperative languages like Forth and descendants, it's usually easy
>enough to write tail recursive functions as loops. If you instead write
>them with tail recursion

It's not about tail recursion, it's about tail-calls. In a call-heavy
language like Forth, that makes quite a bit of a difference. Looking
at <https://www.complang.tuwien.ac.at/forth/peep/sorted>, the sequence
";s ;s" (two returns in the dynamic sequence without other intervening
primitives) has rank 13 (not counting NEXT); eliminating that with
tail call optimization could have reduced the executed NEXTs by 2.65%;
plus, a branch is cheaper than a call.

The downside, of course, is that backtraces no longer contain all the
calls.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<87wngprapl.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17364&group=comp.lang.forth#17364

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Sat, 19 Mar 2022 12:41:58 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87wngprapl.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org> <87o825a2zq.fsf@nightsong.com>
<t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com>
<t0uhor$v0v$1@dont-email.me> <87bky59h1r.fsf@nightsong.com>
<t0uvic$qr9$1@dont-email.me> <87v8wc8288.fsf@nightsong.com>
<t1156o$iu1$1@dont-email.me> <87r16z94ap.fsf@nightsong.com>
<t1185m$54o$1@dont-email.me>
<7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com>
<t151c1$uno$1@dont-email.me> <878rt56cdk.fsf@nightsong.com>
<2022Mar19.195204@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="cb044118230895ec1b29f5febfa0a020";
logging-data="24371"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pjAq3L77AL4Hypgj8wJmQ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:53ToQPwj90D1sumPVQImLO4FKkg=
sha1:eRbPG4Hisg+U8F7W8dDRU0ztMbg=
 by: Paul Rubin - Sat, 19 Mar 2022 19:41 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> It's not about tail recursion, it's about tail-calls. In a call-heavy
> language like Forth, that makes quite a bit of a difference.

Aha, good point. Does gforth get rid of those? I tested and it doesn't
eliminate tail recursion, but maybe that is different.

> The downside, of course, is that backtraces no longer contain all the
> calls.

Perhaps it is appropriate for gforth-fast but not the other variants. I
do like good backtraces.

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar19.225323@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17365&group=comp.lang.forth#17365

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Sat, 19 Mar 2022 21:53:23 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 29
Message-ID: <2022Mar19.225323@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me> <87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me> <87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me> <87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me> <7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com> <t151c1$uno$1@dont-email.me> <878rt56cdk.fsf@nightsong.com> <2022Mar19.195204@mips.complang.tuwien.ac.at> <87wngprapl.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="8a234e4179e22fb314fec1c4693275b5";
logging-data="21510"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183h/G40D1uyapvnDLcc4j0"
Cancel-Lock: sha1:QyAFettn1mWzAgntO4OETb5WLv4=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 19 Mar 2022 21:53 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> It's not about tail recursion, it's about tail-calls. In a call-heavy
>> language like Forth, that makes quite a bit of a difference.
>
>Aha, good point. Does gforth get rid of those?

No.

>I tested and it doesn't
>eliminate tail recursion, but maybe that is different.

If it could optimize tail calls, it could also optimize tail recursion.

>> The downside, of course, is that backtraces no longer contain all the
>> calls.
>
>Perhaps it is appropriate for gforth-fast but not the other variants.

Yes, but that's not the reason why Gforth does not have it. It's just
not that easy to implement in combination with the other things that
Gforth does. Thinking of it, it's not that hard, either.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<22696f9d-0242-4ce3-b548-6d846e154123n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17380&group=comp.lang.forth#17380

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:181:b0:2e1:e70a:ec2a with SMTP id s1-20020a05622a018100b002e1e70aec2amr14308094qtw.42.1647806533167;
Sun, 20 Mar 2022 13:02:13 -0700 (PDT)
X-Received: by 2002:a37:6395:0:b0:67b:1305:4ec3 with SMTP id
x143-20020a376395000000b0067b13054ec3mr11094214qkb.609.1647806532934; Sun, 20
Mar 2022 13:02:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!45.76.7.193.MISMATCH!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 20 Mar 2022 13:02:12 -0700 (PDT)
In-Reply-To: <2022Mar19.225323@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <t0hs0f$80v$1@gioia.aioe.org> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com> <t0uvic$qr9$1@dont-email.me>
<87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me>
<87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me>
<7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com> <t151c1$uno$1@dont-email.me>
<878rt56cdk.fsf@nightsong.com> <2022Mar19.195204@mips.complang.tuwien.ac.at>
<87wngprapl.fsf@nightsong.com> <2022Mar19.225323@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <22696f9d-0242-4ce3-b548-6d846e154123n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Sun, 20 Mar 2022 20:02:13 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 24
 by: Brian Fox - Sun, 20 Mar 2022 20:02 UTC

On Saturday, March 19, 2022 at 5:57:08 PM UTC-4, Anton Ertl wrote:

> >Perhaps it is appropriate for gforth-fast but not the other variants.
> Yes, but that's not the reason why Gforth does not have it. It's just
> not that easy to implement in combination with the other things that
> Gforth does. Thinking of it, it's not that hard, either.
> - anton
> --

I have tail-call removal in a machine Forth compiler that I made
and I was really amazed at how simple it was and how much it
improved program size and speed.

H: -; ( -- )
THERE CELL- @ ( addr ) \ entry address of sub-routine
2 CELLS + ( addr' ) \ move past the sub-routine entry instructions
2 CELLS NEGATE TALLOT \ erase: addr @@ BL,
( addr') @@ B, \ compile a branch to the NEW sub-routine
;H

It's not clear to me how it would be done in an ITC implementation.

Perhaps you have to compile a replacement for DOCOL inline and
compile the BODY of the word right after?

Tail call optimization (was: .Re: Lisp benefits ...)

<2022Mar20.230449@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17382&group=comp.lang.forth#17382

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Tail call optimization (was: .Re: Lisp benefits ...)
Date: Sun, 20 Mar 2022 22:04:49 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 22
Message-ID: <2022Mar20.230449@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <t0uvic$qr9$1@dont-email.me> <87v8wc8288.fsf@nightsong.com> <t1156o$iu1$1@dont-email.me> <87r16z94ap.fsf@nightsong.com> <t1185m$54o$1@dont-email.me> <7d82f345-17ca-4470-81df-d176ee91856an@googlegroups.com> <t151c1$uno$1@dont-email.me> <878rt56cdk.fsf@nightsong.com> <2022Mar19.195204@mips.complang.tuwien.ac.at> <87wngprapl.fsf@nightsong.com> <2022Mar19.225323@mips.complang.tuwien.ac.at> <22696f9d-0242-4ce3-b548-6d846e154123n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="53f8d1dc4f582a946a31715650919540";
logging-data="30437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uHNKE9TGNng7Zu0k7bXom"
Cancel-Lock: sha1:qfoOMdQW7YoS7zTKzv4zENYNedw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 20 Mar 2022 22:04 UTC

Brian Fox <brian.fox@brianfox.ca> writes:
>It's not clear to me how it would be done in an ITC implementation.

Does not look that hard to me. E.g., you could remember where you
last ","ed the CFA of a word. When in ";", if that address is the
preceeding cell, and the code address in the code field is docol
(i.e., the preceeding word is a colon definition), change that word to
BRANCH, and "," the PFA of that word; otherwise just "," the CFA of
";s".

In Gforth it would be more complex, because there is some native code
compiled along with the threaded code. I think the way to go would be
to delay passing along a call to the later stages of compilation. If
the next thing to compile is a ";s", generate a branch, otherwise
generate a call followed by whatever is behind it.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor