Changeset 31095 in project


Ignore:
Timestamp:
07/07/14 09:45:28 (6 years ago)
Author:
sjamaan
Message:

Clarify the use of predicates in C

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/notes-on-chicken.h

    r31089 r31095  
    2424
    2525There are some conventions regarding variables and function names:
    26 ; Predicates : {{p}} at the end of function names generally means {{predicate}} as in [[http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node69.html|Common Lisp]].We can see a bunch of examples from line [[http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=blob;f=chicken.h;h=f5a103ee14314f7c679e01dd8e11c0404043791a;hb=HEAD#l1163|1163]] to 1198. Ex.: {{C_truep(x)}} would be in Scheme equivalent to {{true?}} in {{(define (true? x) (if x #t #f))}}, but returning {{1}} for {{#t}} and {{0}} for {{false}}.
     26; Predicates : {{p}} at the end of function names generally means {{predicate}} as in [[http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node69.html|Common Lisp]].We can see a bunch of examples from line [[http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=blob;f=chicken.h;h=f5a103ee14314f7c679e01dd8e11c0404043791a;hb=HEAD#l1163|1163]] to 1198. Ex.: {{C_truep(x)}} would be in Scheme equivalent to {{true?}} in {{(define (true? x) (if x #t #f))}}. All predicates return Scheme values, but {{C_truep}} is an exception: it returns a C "boolean", ie {{1}} if the value is non-{{#f}} and {{0}} if it is {{#f}}.
    2727
    2828
Note: See TracChangeset for help on using the changeset viewer.