• Why is it ok to have an empty begin but no empty lambda?

    From ceving@21:1/5 to All on Mon Oct 30 06:07:15 2023
    SICP chapter 4 implements begin as a sequence and does not allow empty sequences. But most Schemes allow an empty begin at least at top level.

    For example "(begin)" is ok for Chez, but "(display (begin))" is not. Chibi does not care and displays undef.

    Why is there so much inconsistency? What is the benefit?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkir@21:1/5 to ceving on Mon Oct 30 07:05:02 2023
    ceving schrieb am Montag, 30. Oktober 2023 um 14:07:19 UTC+1:
    SICP chapter 4 implements begin as a sequence and does not allow empty sequences. But most Schemes allow an empty begin at least at top level.

    For example "(begin)" is ok for Chez, but "(display (begin))" is not. Chibi does not care and displays undef.

    Why is there so much inconsistency? What is the benefit?

    Because there are at least two different `begin's. At the top-level and in definition context, `begin' is a splicing form and just splices its contents into the surrounding body. In expression context, `begin' is an expression and thus have to contain
    at least one expression because otherwise it would be unclear which values (if any) to deliver.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkir@21:1/5 to ceving on Mon Oct 30 08:53:22 2023
    ceving schrieb am Montag, 30. Oktober 2023 um 16:50:49 UTC+1:
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 15:05:05 UTC+1:
    Because there are at least two different `begin's.
    Wow: one symbol with two different meanings. This sounds broken.

    Only if confusion or ambiguity could arise.

    Scheme is not a context-free language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ceving@21:1/5 to All on Mon Oct 30 08:50:47 2023
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 15:05:05 UTC+1:
    Because there are at least two different `begin's.

    Wow: one symbol with two different meanings. This sounds broken.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ceving@21:1/5 to All on Tue Oct 31 02:38:43 2023
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 16:53:25 UTC+1:

    Scheme is not a context-free language.

    Which one is wrong?

    1.) Scheme's syntax is given in a Backus-Naur form.
    2.) The Backus-Naur form defines context-free grammars.
    3.) Context-free grammars define context-free languages.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkir@21:1/5 to ceving on Tue Oct 31 02:49:57 2023
    ceving schrieb am Dienstag, 31. Oktober 2023 um 10:38:46 UTC+1:
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 16:53:25 UTC+1:

    Scheme is not a context-free language.
    Which one is wrong?

    1.) Scheme's syntax is given in a Backus-Naur form.
    2.) The Backus-Naur form defines context-free grammars.
    3.) Context-free grammars define context-free languages.

    Scheme's datum syntax is specified by BNF. But Scheme is more than its datum syntax. The same is true for most other programming languages; when a programming language's syntax is specified by BNF, the set of valid programs is usually a proper subset
    of the set of all syntactically valid programs.

    See, for example, "Context Constraints in Wren" on page 13 of https://homepage.divms.uiowa.edu/~slonnegr/plf/Book/Chapter1.pdf for some other background.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tristan Wibberley@21:1/5 to ceving on Sat Mar 2 13:18:01 2024
    On 30/10/2023 15:50, ceving wrote:
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 15:05:05 UTC+1:
    Because there are at least two different `begin's.

    Wow: one symbol with two different meanings. This sounds broken.

    I think it's because (lambda...) is a way to construct a value, and
    (begin...) is a way to sequence actions.

    The term 'lambda' as it applies to logic was described by a group of
    logicians working on systems in general that might not have an atom for *unspecified* so helpfully in scheme if you are to use lambda and return *unspecified* you must do so by explicitly defining the value of the
    lambda in term of something that may be *unspecified*. It's possible the
    scheme language designers didn't appreciate the meaning in logic but
    just followed habits of their forebears.

    Some languages incorporate a lambda more wrongly and allow an implicit *unspecified* because they're actually incorporating a stateful monad
    because they followed *fewer* habits of their forebears.


    cf. imperative vs pure functional languages.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tristan Wibberley@21:1/5 to ceving on Sat Mar 2 15:02:26 2024
    On 30/10/2023 15:50, ceving wrote:
    Marc Nieper-Wißkirchen schrieb am Montag, 30. Oktober 2023 um 15:05:05 UTC+1:
    Because there are at least two different `begin's.

    Wow: one symbol with two different meanings. This sounds broken.

    Sorry for my other post whose context should have been an earlier
    question but which is missing from my newsserver.

    For this question, I did an experiment, and it looks like the special
    meaning is only for a specific local context, in a define with a
    subsequent (values...) expression.

    This plurality is caused by the surrounding context and can be expressed
    with a single meaning for 'begin' albeit a more complex one than you
    would consider in order to not be broken. In particular the behaviour of
    'if' that you seemed concerned about is to support programming styles
    that suit the simpler meaning of 'begin' that you seem to want.

    I am interested to know of programming languages that have no symbols
    with meanings that can be expressed such that two different effects can
    result from its use in two different contexts, and I don't mean things
    that they refer to as symbols, but things which are actually symbols in general.

    I suspect there's no suitable language that satisfies both concerns, in particular I think elimination of actions must allow the complex
    specification of 'begin' in order to also be generally useful, yet
    allowing only actions so that symbols can only have a simpler meaning
    than has 'begin' will make a language too limited to serve scheme
    programmers' purposes.

    Perhaps it is the existence of an explicit syntax-checking threshold and
    that (begin ...) causes either syntax pass or syntax fail depending on
    context? This is common, and often especially desirable, where humans
    will use the language.

    Personally I don't see why begin shouldn't have always required either
    no action and its return value been *unspecified* or always required at
    least one action even if it were the nil action, *unspecified*. The justification for requiring at least one action given in the guile help
    is outside the philosophy that allows (if a b) to exist instead of (if a
    b *unspecified*), which is that the language is not pure functional so expressions can have some kind of *unspecified* atom for their results.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Tristan Wibberley on Sun Mar 3 00:02:16 2024
    On Sat, 2 Mar 2024 13:18:01 +0000, Tristan Wibberley wrote:

    The term 'lambda' as it applies to logic was described by a group of logicians ...

    λ-calculus was first created by Alonzo Church. This was around the same
    time Alan Turing formulated his “Turing machine” to represent computation. The two theories turned out to be equally capable in this regard.

    λ-calculus also offers an interesting way to deal with paradoxes, of the
    kind that scare mathematicians so much: it represents them as an endless
    loop. This is something we are well familiar with in computer science, and it’s not something that scares us.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)