All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stuart Longland <stuartl@longlandclan.id.au>
Cc: ccan@lists.ozlabs.org, Stuart Longland <me@vk4msl.id.au>
Subject: Re: [PATCH] btree: Add custom allocator interface.
Date: Tue, 9 Feb 2016 09:40:57 +1000	[thread overview]
Message-ID: <20160208234057.GC29288@voom.bne.redhat.com> (raw)
In-Reply-To: <56B818F5.7070204@longlandclan.id.au>


[-- Attachment #1.1: Type: text/plain, Size: 1419 bytes --]

On Mon, Feb 08, 2016 at 02:26:29PM +1000, Stuart Longland wrote:
> On 08/02/16 12:17, David Gibson wrote:
> >> +static void* default_malloc(const struct btree_allocator* alloc, size_t size);
> > Existing style in this function suggests "void *foo" rather than
> > "void* foo".
> 
> Ahh, call it habit, I'm used to having the "pointer" bit with the type
> (as to me; "pointer to void" is a distinct type from "void").  Caught
> myself doing it elsewhere but missed it here, I'll fix it.

So, from a language design point of view, I agree with you.  However,
I dislike that style in C because it obscures the fact that C
importantly *does not* have that sensible handling of types.

More specifically this style:
    int*  a, b;

Suggests that a and b have the same type, but of course they don't.

> > [snip]
> >> > +/* Default allocator implementation */
> >> > +const struct btree_allocator BTREE_DEFAULT_ALLOCATOR = {
> > Use of all-caps for a non-macro is a bit unexpected.
> > 
> 
> Good point.  I guess I wanted to visually differentiate a constant from
> other member types.

I applaud the idea, but unfortunately I don't think that use of caps
is common enough to make it really clear.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

  reply	other threads:[~2016-02-09  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07  0:10 [PATCH] btree: Add custom allocator interface stuartl
2016-02-08  0:45 ` Rusty Russell
2016-02-08  2:37   ` Stuart Longland
2016-02-08  3:41     ` Rusty Russell
2016-02-08  4:24       ` Stuart Longland
2016-02-08  2:17 ` David Gibson
2016-02-08  4:26   ` Stuart Longland
2016-02-08 23:40     ` David Gibson [this message]
2016-02-09  2:14       ` Stuart Longland

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

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

  git send-email \
    --in-reply-to=20160208234057.GC29288@voom.bne.redhat.com \
    --to=david@gibson.dropbear.id.au \
    --cc=ccan@lists.ozlabs.org \
    --cc=me@vk4msl.id.au \
    --cc=stuartl@longlandclan.id.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.