unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Linas Vepstas <linasvepstas@gmail.com>
To: Ian Price <ianprice90@googlemail.com>
Cc: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: A bit further toward the flamewar
Date: Fri, 14 Oct 2011 11:23:26 -0500	[thread overview]
Message-ID: <CAHrUA34q+z8xi-P8u7rVEbz9ZHcU-afenY9Y_mYYs2J4Q9y59A@mail.gmail.com> (raw)
In-Reply-To: <m3ipnse5ye.fsf@Kagami.home>

On 13 October 2011 20:07, Ian Price <ianprice90@googlemail.com> wrote:
> Linas Vepstas <linasvepstas@gmail.com> writes:
>
>> I have no clue why it never occurred to me to use the above paradigm,
>> I will definitely start experimenting with it.
>>
>> Any clue on how to indicate that func returns type 'X' ?
>>
>> I don't know if you were trying to make this point but: if one were to
>> code in the above paradigm, and also throw some srfi-9000 syntactic
>> sugar at it, one might  be able to get something that resembled
>> ocaml/haskell type declarations.  And, for the code that I deal with,
>> this might be the bees knees.
>
> Just because scheme doesn't have type declarations doesn't mean you
> can't add them. I often write code that looks like
>
> ; partition : (A -> Boolean) Listof(A) -> Listof(A) Listof(A)
> (define (partition pred list) ...)
>
> and I also make heavy use of 'assert', and less frequently, a macro of
> mine called 'assert-lambda' which looks like
>
> (lambda ((a procedure?) (b list?)) ...)
>
> I don't, in general, check return types, but I do try and make sure that
> they obey the declaration comment. Having a built-in type/contract
> syntax, like Racket has, would be nice as I could move these comments
> into code, but this is better than nothing.

Well, I see two choices:
1) Let the conversation slide, and incorporate above thoughts as 'best
practices' into my code.
2) Flame-war.

In the spirit of 2),

Andy Wingo wrote:
> I can't find the source right now, but I think it was Matthias Felleisen
> who gave a variant of Greenspun's tenth law, that "any sufficiently
> complex Lisp program has a buggy, incomplete ML program in the
> comments".

So the proposal is: (shout me down, when ready): create a new srfi,
defining an ML-like conception of types, so that scheme functions can
be annotated with types. The goal here is not so much to do
type-checking at run-time, but to allow static type checking.   That
is, one could create a "type checker tool", which one could invoke
ad-hoc, during development, to make sure that my scheme programs are
consistent with their handling of types. This is static type checking
--  as, for the most part, I am not interested in type-checking during
runtime, for two reasons: performance, and also because I want to
avoid the hard-to-debug problem where I only pass the wrong type only
once in a million.

Basically, as a debugging/development tool, everything I've read about
ML (e.g. the Jane's street commentary) is that the static
type-checking in ML is a powerful means of avoiding developer errors.
It'd be neat if I could get this feature in scheme.

BTW, as a token nod to C: please be aware that the Linux Kernel folks
have been busy creating and extending a static type-checking system
for C, which is used extensively in the linux kernel sources. The goal
there is to avoid accidentally passing user-space pointers into the
kernel (where they are invalid), and to avoid calls to __init routines
during runtime (because they no longer exist after initialization).
Note that this kind of type-checking is not possible in "ordinary" C.
I can't comment on how "well-designed" the system is, but it has been
very effective in finding zillions of bugs in the linux kernel.

--linas



  parent reply	other threads:[~2011-10-14 16:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 14:54 Why is guile still so slow? John Lewis
2011-10-12 15:39 ` rixed
2011-10-12 18:56   ` Jose A. Ortega Ruiz
2011-10-12 22:40     ` rixed
2011-10-12 23:56       ` Jose A. Ortega Ruiz
2011-10-13  6:23         ` rixed
2011-10-13 10:22     ` Andy Wingo
2011-10-13 11:27       ` A bit further toward the flamewar rixed
2011-10-13 14:26         ` Ludovic Courtès
2011-10-13 15:20           ` Andy Wingo
2011-10-13 16:30             ` Linas Vepstas
2011-10-13 18:37               ` Mike Gran
2011-10-13 21:42                 ` Linas Vepstas
2011-10-13 22:08                   ` dskr
2011-10-14  1:07                   ` Ian Price
2011-10-14  8:40                     ` Andy Wingo
2011-10-14 16:23                     ` Linas Vepstas [this message]
2011-10-15  8:44                       ` Andy Wingo
2011-10-14  8:28                   ` Andy Wingo
2011-10-14 16:30                     ` Linas Vepstas
2011-10-14 17:26                       ` Andy Wingo
2011-10-13 19:16               ` Hans Aberg
2011-10-14  9:57               ` Panicz Maciej Godek
2011-10-13 17:43             ` Ludovic Courtès
2011-10-13 18:54           ` rixed
2011-10-13 21:14             ` Ludovic Courtès
2011-10-13 21:58               ` Hans Aberg
2011-10-14  9:28                 ` Ludovic Courtès
2011-10-14 10:53                   ` Hans Aberg
2011-10-14  9:37               ` rixed
2011-10-14 20:05                 ` Ludovic Courtès
2011-10-12 15:52 ` Why is guile still so slow? Andy Wingo
2011-10-12 16:19 ` John Lewis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHrUA34q+z8xi-P8u7rVEbz9ZHcU-afenY9Y_mYYs2J4Q9y59A@mail.gmail.com \
    --to=linasvepstas@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=ianprice90@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).