initial announcement of guile-termite

2013-08-20 Thread Chaos Eternal
Termite is an erlang-style concurrent programming framework
oringinally developed on Gambit-C scheme.
the guile-termite is a port of the framework to gnu guile.

currently finished the thread-mailbox part.

the code is accessible https://github.com/ChaosEternal/guile-termite
It is licensed under LGPLv3

comments, bug reports, critiques are welcome.



Define in let

2013-08-20 Thread Dmitry Bogatov

It seems following is invalid:

   (let ((a 2))
(define (foo x) (+ a x)))

I prefer to reduce scope of variable as much as possible, so
I find this restriction unconvinent. Is is part of standard or technical
limitation? Is it any workaround?

Please, keep in CC, I am not subscribed.

--
Best regards, Dmitry Bogatov ,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.


pgp3VBKJa41ZR.pgp
Description: PGP signature


Re: Define in let

2013-08-20 Thread Thompson, David
On Tue, Aug 20, 2013 at 12:39 PM, Dmitry Bogatov  wrote:

>
> It seems following is invalid:
>
>(let ((a 2))
> (define (foo x) (+ a x)))
>
> I prefer to reduce scope of variable as much as possible, so
> I find this restriction unconvinent. Is is part of standard or technical
> limitation? Is it any workaround?
>


The problem is that you have an invalid `let` form. You need an expression
besides `define`.

Something like this would be valid:

(let ((a 2))
  (define (foo x) (+ a x))
  (foo 4))


>
> Please, keep in CC, I am not subscribed.
>
> --
> Best regards, Dmitry Bogatov ,
> Free Software supporter and netiquette guardian.
> git clone git://kaction.name/rc-files.git --depth 1
> GPG: 54B7F00D
> Html mail and proprietary format attachments are forwarded to /dev/null.
>

- Dave Thompson


Re: Define in let

2013-08-20 Thread Taylan Ulrich B.
Dmitry Bogatov  writes:

> It seems following is invalid:
>
>(let ((a 2))
> (define (foo x) (+ a x)))
>
> I prefer to reduce scope of variable as much as possible, so
> I find this restriction unconvinent. Is is part of standard or technical
> limitation? Is it any workaround?
>
> Please, keep in CC, I am not subscribed.
>
> --
> Best regards, Dmitry Bogatov ,
> Free Software supporter and netiquette guardian.
>   git clone git://kaction.name/rc-files.git --depth 1
>   GPG: 54B7F00D
> Html mail and proprietary format attachments are forwarded to /dev/null.

No Scheme standard so far has supported such a thing, and neither Guile.

It would be neat, I had the idea too (it would allow re-use of the
semantics of `begin' and thus be coherent/orthogonal in a way), but I
think it's a non-trivial change, probably both to the implementation of
Guile and the semantics for `let' that have been well-understood ever
since very old Lisps: that `let' is a thin wrapper around a call to an
in-place `lambda'.

(let ((a x)
  (b y))
  ...)

is just

((lambda (a b)
   ...)
 x y)

in pretty much any Lisp.

Note that you can do

(define foo
  (let ((a 2))
(lambda (x) (+ a x

and if you want to define multiple things that use that `a' binding, you
could use `define-values', but Guile doesn't have that yet (there's a
hacky in-Scheme definition in R7RS-small if you want something quick):

(define-values (foo bar)
  (let ((a 2))
(values
 (lambda (x) (+ a x))
 (lambda (y) (* a y)

Taylan



Re: Define in let

2013-08-20 Thread Ian Price
Dmitry Bogatov  writes:

> It seems following is invalid:
>
>(let ((a 2))
> (define (foo x) (+ a x)))
>
> I prefer to reduce scope of variable as much as possible, so
> I find this restriction unconvinent. Is is part of standard or technical
> limitation? Is it any workaround?

It's not a limitation, but a misunderstanding. Define creates a binding
in the _current_ scope, not the top level one.


-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



Re: Define in let

2013-08-20 Thread Mike Gran
> From: Dmitry Bogatov 

> It seems following is invalid:
> 
>    (let ((a 2))
>         (define (foo x) (+ a x)))
> 

Perhaps something like

(let* ((a 2)
   (foo (lambda (x) (+ a x
  (foo 

-Mike




Re: Define in let

2013-08-20 Thread John B. Brodie
On 08/20/2013 12:39 PM, Dmitry Bogatov wrote:
> It seems following is invalid:
>
>(let ((a 2))
> (define (foo x) (+ a x)))
>
> I prefer to reduce scope of variable as much as possible, so
> I find this restriction unconvinent. Is is part of standard or technical
> limitation? Is it any workaround?

use a lambda form rather than a define:

(letrec ((a 2)
 (foo (lambda (x) (+ a x
 (foo 3))

>
> Please, keep in CC, I am not subscribed.
>
> --
> Best regards, Dmitry Bogatov ,
> Free Software supporter and netiquette guardian.
>   git clone git://kaction.name/rc-files.git --depth 1
>   GPG: 54B7F00D
> Html mail and proprietary format attachments are forwarded to /dev/null.




Re: Define in let

2013-08-20 Thread David Pirotte
Hello,

> It seems following is invalid:
> 
>(let ((a 2))
> (define (foo x) (+ a x)))
> 
> I prefer to reduce scope of variable as much as possible, so
> I find this restriction unconvinent. Is is part of standard or technical
> limitation? Is it any workaround?

Section '3.4.7 Example 2: A Shared Persistent Variable' is probably what you 
want?

Cheers,
David