unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: [PATCH] Colorized REPL
Date: Sat, 12 Jan 2013 22:16:32 +0100	[thread overview]
Message-ID: <8738y6umof.fsf@gnu.org> (raw)
In-Reply-To: CAN3veRfU=A8qhJHjhbyhKzWB9xyrcU85=f1G4n1nbRLeB16OZQ@mail.gmail.com

Hi Daniel,

Daniel Hartwig <mandyke@gmail.com> skribis:

> On 11 January 2013 22:33, Ludovic Courtès <ludo@gnu.org> wrote:

[...]

>> I still think that using a disjoint type for
>> colors would be better than symbols.
>
> These are arbitrary control codes and can be applied in any
> combination.  Essentially, the best you can do with a disjoint type
> is:
>
> (define-record-type foo
>   (make-foo name code) …
>
> Which you would still need a dictionary to look them up by name, or
> export a binding for every code and combination, or provide additional
> operators to combine them …

Hmm.

> List of symbols is a convenient abstraction over the natural form:
> list of control codes.  Embedding this in to a record with named and
> function-presuming fields is too much and needlessly complicated, IMO.
>
> List of symbols is also compatible with the interface established by
> the earlier guile-lib module, for whatever that is worth.
>
> Using list of symbols:
>
> (colorize-string "foo" '(RED))
> (colorize-string "foo" '(BOLD ON-CYAN))
>
> It is not clear to me the interface you are proposed at this level.
> Will you provide counter examples to these two calls?

In general, using symbols like this amounts to introducing an alternate
name space, with its own rules, and its own support (or lack thereof).
For instance, if you use variables to hold colors, you could write:

  (colorize-string "foo" red)
  (colorize-string "foo" (with-background cyan bold))

And you get unbound variable warnings and errors if there’s a typo, a
type error if you’re passing something unrelated, etc.

That’s why as a rule of thumb I prefer disjoint types and variables for
singleton instances.

Now, there may be cases where this is overkill, or not appropriate for
some reason.  I’m not completely sure about ANSI escapes, so perhaps
you’re right that what I suggest is inappropriate.  Yet, the RED,
ON-CYAN, etc. symbols look ugly to me as an abstraction.

Thanks,
Ludo’.




  parent reply	other threads:[~2013-01-12 21:16 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05  7:21 [PATCH] Colorized REPL Nala Ginrut
2012-12-05  8:23 ` Daniel Hartwig
2012-12-05  8:48   ` Nala Ginrut
2012-12-05  9:02     ` Nala Ginrut
2012-12-05  9:45     ` Daniel Hartwig
2012-12-05 10:27       ` Nala Ginrut
2012-12-05 11:19         ` Daniel Hartwig
2012-12-06  2:43           ` Nala Ginrut
2012-12-06  3:09             ` Daniel Hartwig
2012-12-06  4:28               ` Nala Ginrut
2012-12-06  5:30                 ` Daniel Hartwig
2012-12-09 23:29           ` Ludovic Courtès
2012-12-10  2:23             ` Nala Ginrut
2012-12-10 21:42               ` Ludovic Courtès
2012-12-11  2:31                 ` Nala Ginrut
2012-12-11 14:13                   ` Nala Ginrut
2012-12-31  8:29                 ` Nala Ginrut
2013-01-04 14:06                   ` Ludovic Courtès
2013-01-04 16:57                     ` Mike Gran
2013-01-09 10:17                     ` Nala Ginrut
     [not found]                       ` <CAN3veRfF5muf+zrfdU7ZogDw=YboW=QRP08zTF6NUeKzDJ__uA@mail.gmail.com>
2013-01-10  8:20                         ` Daniel Hartwig
2013-01-11  6:29                         ` Nala Ginrut
2013-01-11  8:13                           ` Daniel Hartwig
2013-01-11 10:40                             ` Nala Ginrut
2013-01-12  1:01                               ` Daniel Hartwig
2013-01-11 14:33                       ` Ludovic Courtès
2013-01-11 17:20                         ` Noah Lavine
2013-01-11 23:26                           ` Ludovic Courtès
2013-01-12 15:35                             ` Noah Lavine
2013-01-13 21:01                               ` Ludovic Courtès
2013-01-12  0:26                         ` Daniel Hartwig
2013-01-12  9:59                           ` Nala Ginrut
2013-01-12 21:16                           ` Ludovic Courtès [this message]
2013-01-26 10:15                             ` Nala Ginrut
2013-01-27 10:06                               ` Andy Wingo
2013-01-28  4:14                                 ` Nala Ginrut
2013-01-28 13:58                                   ` David Pirotte
2013-01-28 14:56                                     ` Nala Ginrut
2013-01-31 14:25                                       ` Nala Ginrut
2013-01-31 14:31                                         ` Nala Ginrut
2013-01-31 16:51                                           ` Nala Ginrut
2013-01-21 16:10                         ` Nala Ginrut
2013-01-22 11:06                         ` Nala Ginrut
     [not found] <mailman.913570.1354697338.854.guile-devel@gnu.org>
2012-12-05  9:50 ` Daniel Llorens
2012-12-05  9:57   ` Nala Ginrut
2012-12-05 10:11   ` Daniel Hartwig
2012-12-08 21:35   ` Ian Price
2012-12-09  0:50     ` Daniel Hartwig
2012-12-09 10:44       ` Nala Ginrut
2012-12-17  6:04       ` Nala Ginrut
2013-01-21 20:18   ` Andy Wingo
2013-01-28 10:57     ` Nala Ginrut

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=8738y6umof.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    /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).