Re: and-let* is not composable?

2013-09-11 Thread Panicz Maciej Godek
2013/9/10 Ian Price 

>
> I have a few notes unrelated to those I've already mentioned in the
> thread.
>
> 1. Guile already has curried definitions in (ice-9 curried-definitions)
>
> Yes, but those are completely different. I wouldn't call "define-curried"
a curried definition, but a definition of a curried macro for generating
procedures.


> 2. By turning your functions definitions into a macro, you've lost the
> ability to use them in a first class manner.
>
> That's not entirely true. I just need an extra pair of parentheses
to do so. The semantics is certainly different than the one of
Guile's curried definitions, but that's fine.


> 3. I would strongly recommend _not_ using define-macro, and even more
> so, not mixing define-macro and syntax-rules in a macro. Syntax-case is
> as powerful as defmacro, and in most practical cases, about as much
> writing.
>

Well, while syntax-rules macros are quite easy to understand
(at least from the user's point of view), although sometimes a little
tricky, the syntax-case system I find still too difficult to use.
define-macro, on the other hand, is very easy to explain
even to beginner programmers, although the resulting macros
are much more difficult to analyse.
The main problem with syntax-rules/syntax-case macros is
the treatment of ellipses, which makes it difficult to create
macros that create macros.
Still, I didn't post to comp.lang.scheme for no reason :)

4. What your macro does is not currying, it is partial
> application. Those are different things. Currying refers to the process
> of turning a function of n arguments into an n-nested set of 1 argument
> functions. Partial application is, well, not supplying all the arguments
> to a function. You can have partial application without currying, as
> your macro shows.
>

OK, you got me here. But it's still difficult for me to come up
with a good name for that macro (and if so, the Guile's curried
definitions are not curried either, at least in general: because
you can (define ((f a b) c d) ...), getting a chain of 2-argument
functions)

Thanks,
M.


Re: and-let* is not composable?

2013-09-11 Thread Ian Price
Panicz Maciej Godek  writes:

> That's not entirely true. I just need an extra pair of parentheses
> to do so. The semantics is certainly different than the one of
> Guile's curried definitions, but that's fine.
An identifier macro would be even better, but it's still not first
class.

> Well, while syntax-rules macros are quite easy to understand
> (at least from the user's point of view), although sometimes a little
> tricky, the syntax-case system I find still too difficult to use.
> define-macro, on the other hand, is very easy to explain
> even to beginner programmers, although the resulting macros
> are much more difficult to analyse.
If you, or the other people who are confused by syntax-case, can point
to the parts of the manual that confuse you, so we can clear them up, I
think we'd all appreciate it.

Fundamentally, syntax-case shouldn't be harder to use than define-macro
99% of the time, if you remember

- macros are functions from "syntax-objects" to syntax-objects
- syntax-objects are smart symbols
- syntax->datum to remove the smartness
- datum->syntax is for when you want to break hygiene (but syntax
  parameters are better where applicable)
- use quasisyntax to construct lists of syntax-objects instead of
  quasiquote to construct lists of symbols.

> The main problem with syntax-rules/syntax-case macros is
> the treatment of ellipses, which makes it difficult to create
> macros that create macros.
You can expand into ellipses with (... ...), it's ugly, but it's there.

> with a good name for that macro (and if so, the Guile's curried
> definitions are not curried either, at least in general: because
> you can (define ((f a b) c d) ...), getting a chain of 2-argument
> functions)
Indeed, I wasn't sure whether or not I should have mentioned it, but I
was told this is the "correct" name for that feature on comp.lang.scheme
a while back. I think it might have been Will Clinger, but I'd need to
double check.

-- 
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"



Doctest for guile

2013-09-11 Thread Dmitry Bogatov

Hello!
I am glad to offer implementation of doctest in Guile --- way to declare
and check tests in function docstring. In most simple way, if in
docstring you write following:

+++ (foo 1 2 3)
--- 6

doctests will check if it is really so. I belive it encourage writing
more modular, generic and pure function. Also, such tests helps to
understand function behavior on corner cases.

This is just proof-of-concept, that offer following:

+ test of multiple values
+ testing of not-exported functions.

You can just download attached archive(I belive it small enough to not
bother with ftp) and do following:
$ tar xf doctest.tar.gz
$ cd doctest
$ export GUILE_LOAD_PATH=$PWD
$ guile doctest.scm '(foo)'
## Two successful tests, one failure
## If no modules specified, doctest tests itself
$ guile doctest.scm

But much more is todo:

+ contollable verbosity
+ exit status on failed tests
+ shortcut for predicates
+ it crashes on input like this:

+++ (foo 1 2 3
--- 6
+ there is no way to say that test should throw
+ Your ideas?

I it will be found useful enough, I will gladly work on patch to integrate
doctest in Guile guild script.



doctest.tar.gz
Description: Tarball of doctest sources

--
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.


pgph69FiC4WS4.pgp
Description: PGP signature


Re: Problem with wide characters on upgrading to guile 2.x

2013-09-11 Thread Richard Shann
On Sat, 2013-09-07 at 11:07 +0200, Andy Wingo wrote:
> On Mon 02 Sep 2013 10:48, Richard Shann  writes:
> 
> > On Thu, 2013-08-22 at 12:14 -0700, Mike Gran wrote:
> >> >>  2. In the inner_main of your scm_with_guile call, 
> >> 
> >> >>  try calling scm_setlocale.  Maybe something like this?
> >> >>  (This shouldn't make a difference, I think. 
> >> >>  But, if it does, it says something interesting.)
> >> >> 
> >> >>  scm_setlocale( scm_variable_ref(scm_c_lookup("LC_ALL")), 
> >> > scm_from_locale_string("") );
> >> > 
> >> >>   If that actually works, lemme know.
[...]
> >
> > ERROR: In procedure catch-closure:
> > ERROR: In procedure setlocale: Invalid argument
> > 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> 
> const char prog[] =
>   "(catch #t
>  (lambda () (setlocale LC_ALL \"\"))
>  (lambda _
>(display \"Locale not supported by the C library.
> Falling back to default \\\"C\\\" locale.\\n\"
> (current-error-port";
> scm_c_eval_string (prog);
> 
> Andy

Thank you! That does nicely.

Richard





pretty-print for 1+

2013-09-11 Thread Brian Killian
Using guile 2.0.9 and the ice-9 pretty-print module, when I apply:

(pretty-print '(1+ 1))

I get:

(#{1+}# 1)

I was expecting:

(1+ 1)

Is this an issue with pretty-print or should I adjust my expectation?