Re: Double Parenthesis

2020-02-09 Thread Freeman Gilmore
  I did not see this when i replied last , so let me read it i loos like it
is the answer i want.
Thank you,ƒg

On Sun, Feb 9, 2020 at 12:38 PM David Kastrup  wrote:

> Freeman Gilmore  writes:
>
> > On Sun, Feb 9, 2020 at 9:33 AM Thomas Morley 
> > wrote:
> >
> >> Am So., 9. Feb. 2020 um 15:02 Uhr schrieb Freeman Gilmore
> >> :
> >> >
> >> >
> >> >
> >> > This is taken from the "Scheme Book".
> >> >
> >> > Question why double parenthesis  for  let ((rand (random 100))) ?
> >> >
> >> > Thank you, ƒg
> >>
> >> Well, every expression needs to be wrapped into parenthesis.
> >>
> >> One pair for the let-expression:
> >> (let ...)
> >>
> >> One pair for all local-bindings:
> >> (let (all-local-bindings) ...)
> >>
> > I understand the above and below but not this  let ((rand (random 100)))
> > Put in your form:   (let ((rand (random 100))) ...)
>
> In Scheme, there is no such thing as a redundant parenthesis.  Every
> parenthesis has meaning.
>
> bla
>
> at top level is a variable.
>
> (bla)
>
> takes the value of the variable and calls it as a function.
>
> ((bla))
>
> takes the value this function returns, and calls _that_ as a function.
>
> So the question boils down to: why was the syntax of let designed in a
> way requiring so many parentheses?
>
> Now the basic syntax of let is
>
> (let [local bindings] [cmd] ...)
>
> In order to recognise where the first command starts, [local bindings]
> can only be a single item, but since we can have more than a single
> binding, we need to have it delimited, and in constructs as old as let,
> there is no delimiter but parentheses.
>
> So now we have
>
> (let ([local binding] ...) [cmd] ...)
>
> Now how should [local binding] look?  It could be [variable] [value],
> making for
>
> (let (x 1 y 4) ...)
>
> but for one thing, this gets ugly to read when we have something like
>
> (let (x y z t) ...)
>
> which in actual syntax looks like (let ((x y) (z t)) ...) .  And for
> another, in the old ancestor Lisp, (let (x y z t) ...) actual has
> separate meaning and changing that established meaning would really
> confuse people.  Quoting (out of laziness) from Elisp:
>
> let is a special form in ‘C source code’.
>
> (let VARLIST BODY...)
>
>   Probably introduced at or before Emacs version 1.12.
>
> Bind variables according to VARLIST then eval BODY.
> The value of the last form in BODY is returned.
> Each element of VARLIST is a symbol (which is bound to nil)
> or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of
> VALUEFORM).
> All the VALUEFORMs are evalled before any symbols are bound.
>
> [back]
>
> So adding one layer of parens around variable and value (if there are to
> be both) seems called for.
>
> And that's what you get.
>
> > Here is another example from the book, why double parenthesis ((assq
> > 'col-darkblue colors)).
>
> That doesn't occur in a vacuum, so it would appear that you are missing
> context here.
>
> --
> David Kastrup
> My replies have a tendency to cause friction.  To help mitigating
> damage, feel free to forward problematic posts to me adding a subject
> like "timeout 1d" (for a suggested timeout of 1 day) or "offensive".
>


Re: Double Parenthesis

2020-02-09 Thread Kieren MacMillan
Hi Freeman,

> This is the form i am asking about:
>   (let
> (
> (rand (random 100))
> )
>  (
>...
>  )
>   )

In that form, the … is where the procedure(s) for the let function would 
appear, though I’d probably indent it like this instead:

(let
(
(rand (random 100))
)
(
...
)
)

Now… what exactly is your question about that form?

Best,
Kieren.


Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info




Re: Double Parenthesis

2020-02-09 Thread Freeman Gilmore
On Sun, Feb 9, 2020 at 12:25 PM Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi Freeman,
>
> > Ok you are getting closer to what i am asking.
>
> I’m glad!
>
> > Rerote(let ((rand (random 100))) ...) .I need to understand it
> so that i know which to use and when?
> >  ((rand (random 100)) or (rand (random 100)
>
> You would never use either, because the parentheses aren’t
> matched/paired/balanced.  ;)
>
> >   for (let ((rand (random 100))) ...) or (let(rand (random 100)) ...) .
>

In your previous email you explained this: ((rand (random 100)))  for
let ((rand
(random 100))) which is ((let ((rand (random 100)))...)

>
> As Harm pointed out, indentation will help… Here’s an extremely
> broken-down version:
>
> (let
> (
> (rand (random 100))
> (a (+ 2 3))
> )
> )
>
This is the form i am asking about:
  (let
(
(rand (random 100))
)
 (
   ...
 )
  )


>
> Compressing it onto a single line [which is not necessarily encouraged]
> gives:
>
> (let ((rand (random 100)) (a (+ 2 3
>
> Hope that helps!
> Kieren.
> 
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>


Re: Double Parenthesis

2020-02-09 Thread David Kastrup
Freeman Gilmore  writes:

> On Sun, Feb 9, 2020 at 9:33 AM Thomas Morley 
> wrote:
>
>> Am So., 9. Feb. 2020 um 15:02 Uhr schrieb Freeman Gilmore
>> :
>> >
>> >
>> >
>> > This is taken from the "Scheme Book".
>> >
>> > Question why double parenthesis  for  let ((rand (random 100))) ?
>> >
>> > Thank you, ƒg
>>
>> Well, every expression needs to be wrapped into parenthesis.
>>
>> One pair for the let-expression:
>> (let ...)
>>
>> One pair for all local-bindings:
>> (let (all-local-bindings) ...)
>>
> I understand the above and below but not this  let ((rand (random 100)))
> Put in your form:   (let ((rand (random 100))) ...)

In Scheme, there is no such thing as a redundant parenthesis.  Every
parenthesis has meaning.

bla

at top level is a variable.

(bla)

takes the value of the variable and calls it as a function.

((bla))

takes the value this function returns, and calls _that_ as a function.

So the question boils down to: why was the syntax of let designed in a
way requiring so many parentheses?

Now the basic syntax of let is

(let [local bindings] [cmd] ...)

In order to recognise where the first command starts, [local bindings]
can only be a single item, but since we can have more than a single
binding, we need to have it delimited, and in constructs as old as let,
there is no delimiter but parentheses.

So now we have

(let ([local binding] ...) [cmd] ...)

Now how should [local binding] look?  It could be [variable] [value],
making for

(let (x 1 y 4) ...)

but for one thing, this gets ugly to read when we have something like

(let (x y z t) ...)

which in actual syntax looks like (let ((x y) (z t)) ...) .  And for
another, in the old ancestor Lisp, (let (x y z t) ...) actual has
separate meaning and changing that established meaning would really
confuse people.  Quoting (out of laziness) from Elisp:

let is a special form in ‘C source code’.

(let VARLIST BODY...)

  Probably introduced at or before Emacs version 1.12.

Bind variables according to VARLIST then eval BODY.
The value of the last form in BODY is returned.
Each element of VARLIST is a symbol (which is bound to nil)
or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
All the VALUEFORMs are evalled before any symbols are bound.

[back]

So adding one layer of parens around variable and value (if there are to
be both) seems called for.

And that's what you get.

> Here is another example from the book, why double parenthesis ((assq
> 'col-darkblue colors)).

That doesn't occur in a vacuum, so it would appear that you are missing
context here.

-- 
David Kastrup
My replies have a tendency to cause friction.  To help mitigating
damage, feel free to forward problematic posts to me adding a subject
like "timeout 1d" (for a suggested timeout of 1 day) or "offensive".



Re: Double Parenthesis

2020-02-09 Thread Kieren MacMillan
Hi Freeman,

> Ok you are getting closer to what i am asking.

I’m glad!

> Rerote(let ((rand (random 100))) ...) .I need to understand it so 
> that i know which to use and when?
>  ((rand (random 100)) or (rand (random 100)

You would never use either, because the parentheses aren’t 
matched/paired/balanced.  ;)

>   for (let ((rand (random 100))) ...) or (let(rand (random 100)) ...) .

As Harm pointed out, indentation will help… Here’s an extremely broken-down 
version:

(let
(
(rand (random 100))
(a (+ 2 3))
)
)

Compressing it onto a single line [which is not necessarily encouraged] gives:

(let ((rand (random 100)) (a (+ 2 3

Hope that helps!
Kieren.


Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info




Re: Double Parenthesis

2020-02-09 Thread Freeman Gilmore
On Sun, Feb 9, 2020 at 11:45 AM Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi Freeman,
>
> > I understand the above and below but not this  let ((rand (random
> 100)))
> > Put in your form:   (let ((rand (random 100))) ...)
>
> Here are the thoughts of a Scheme newbie — hopefully they are correct!  =)
>
> Working from the inside out:
>
> The first set of parentheses is needed to encapsulate the random number
> procedure/expression:
>
>   (random 100)
>
> The second set of parentheses associates that procedure/expression (a.k.a.
> result) with a variable [to be set using Let]:
>
>   (rand (random 100))
>
> The third set encloses the "complete set of [Let] variables":
>
>   ((rand (random 100)))
>
Ok you are getting closer to what i am asking.

>
> The fourth set [in Harm’s form] is for the Let procedure/expression itself:
>
>   (let ((rand (random 100)))

Rerote(let ((rand (random 100))) ...) .I need to understand it so
that i know which to use and when?
 ((rand (random 100)) or (rand (random 100)  for (let ((rand (random 100)))
...) or (let(rand (random 100)) ...) .

Thank you, ƒg






>
> Hope that helps you understand it!
> Kieren.
> 
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>


Re: Double Parenthesis

2020-02-09 Thread Kieren MacMillan
Hi Freeman,

> I understand the above and below but not this  let ((rand (random 100)))  
> Put in your form:   (let ((rand (random 100))) ...) 

Here are the thoughts of a Scheme newbie — hopefully they are correct!  =)

Working from the inside out:

The first set of parentheses is needed to encapsulate the random number 
procedure/expression:

  (random 100)

The second set of parentheses associates that procedure/expression (a.k.a. 
result) with a variable [to be set using Let]:

  (rand (random 100))

The third set encloses the "complete set of [Let] variables":

  ((rand (random 100)))

The fourth set [in Harm’s form] is for the Let procedure/expression itself:

  (let ((rand (random 100

Hope that helps you understand it!
Kieren.


Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info




Re: Double Parenthesis

2020-02-09 Thread Freeman Gilmore
On Sun, Feb 9, 2020 at 9:33 AM Thomas Morley 
wrote:

> Am So., 9. Feb. 2020 um 15:02 Uhr schrieb Freeman Gilmore
> :
> >
> >
> >
> > This is taken from the "Scheme Book".
> >
> > Question why double parenthesis  for  let ((rand (random 100))) ?
> >
> > Thank you, ƒg
>
> Well, every expression needs to be wrapped into parenthesis.
>
> One pair for the let-expression:
> (let ...)
>
> One pair for all local-bindings:
> (let (all-local-bindings) ...)
>
I understand the above and below but not this  let ((rand (random 100)))
Put in your form:   (let ((rand (random 100))) ...)

Here is another example from the book, why double parenthesis ((assq
'col-darkblue colors)).

Thank for all you work here, ƒg

One pair for each single local binding, note every local binding is of
> type key-value:
> (let (  (key1 value1) (key2 value2) ) ...)
>
> Every value my be a procedure call, with the need for another pair of
> parenthesis:
> (let ( (key1 (proc1 args1)) (key2 (proc2 args2)) ) ...)
>
> Proper indentation increases readability:
> (let (
>   (key1 (proc1 args1))
>   (key2 (proc2 args2))
>  )
>...
>)
>
> HTH,
>   Harm
>


Re: Double Parenthesis

2020-02-09 Thread Thomas Morley
Am So., 9. Feb. 2020 um 15:02 Uhr schrieb Freeman Gilmore
:
>
>
>
> This is taken from the "Scheme Book".
>
> Question why double parenthesis  for  let ((rand (random 100))) ?
>
> Thank you, ƒg

Well, every expression needs to be wrapped into parenthesis.

One pair for the let-expression:
(let ...)

One pair for all local-bindings:
(let (all-local-bindings) ...)

One pair for each single local binding, note every local binding is of
type key-value:
(let (  (key1 value1) (key2 value2) ) ...)

Every value my be a procedure call, with the need for another pair of
parenthesis:
(let ( (key1 (proc1 args1)) (key2 (proc2 args2)) ) ...)

Proper indentation increases readability:
(let (
  (key1 (proc1 args1))
  (key2 (proc2 args2))
 )
   ...
   )

HTH,
  Harm



Re: Double Parenthesis

2020-02-09 Thread Malte Meyn




Am 09.02.20 um 15:02 schrieb Freeman Gilmore:

This is taken from the "Scheme Book".

Question why double parenthesis  for  let ((rand (random 100))) ?


A let expression can have several definitions, f. e.

(let
  (
(rand (random 100))
(notrand (* 6 7))
  )
  […]
)



Double Parenthesis

2020-02-09 Thread Freeman Gilmore
This is taken from the "Scheme Book".

Question why double parenthesis  for  let ((rand (random 100))) ?

Thank you, ƒg