Changeset 35621 in project


Ignore:
Timestamp:
06/20/18 20:53:33 (3 months ago)
Author:
sjamaan
Message:

Add an example of how I ported uri-generic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/porting-c4-to-c5

    r35618 r35621  
    4242If your code is wrapped in a module, eventually, you'll be left only
    4343with errors about missing imports, and cascade-style errors caused by
    44 missing macros (these can be very misleading, so pay attention!).
    45 For example:
     44missing macros (these can be very misleading, so pay attention!).  For
     45example, when I was porting the [[/eggref/5/uri-generic|uri-generic
     46egg]], I got this list after I had replaced {{use}} by {{import}} and
     47installed the requisite SRFI eggs:
     48
     49    Warning: reference to possibly unbound identifier `->string' in:
     50    Warning:    uri-normalize-case
     51    Warning:    suggesting: `(import chicken.string)'
     52   
     53    Warning: reference to possibly unbound identifier `conc'
     54    Warning:    suggesting: `(import chicken.string)'
     55   
     56    Warning: reference to possibly unbound identifier `reverse-list->string' in:
     57    Warning:    uri-char-list->string
     58    Warning:    suggesting: `(import chicken.string)'
     59   
     60    Warning: reference to possibly unbound identifier `string-intersperse' in:
     61    Warning:    join-segments
     62    Warning:    suggesting: `(import chicken.string)'
     63   
     64    Warning: reference to possibly unbound identifier `with-output-to-string' in:
     65    Warning:    uri->string
     66    Warning:    suggesting: `(import chicken.port)'
     67   
     68    Warning: reference to possibly unbound identifier `fprintf'
     69    Warning:    suggesting: `(import chicken.format)'
     70   
     71    Warning: reference to possibly unbound identifier `out'
     72   
     73    Warning: reference to possibly unbound identifier `x'
     74   
     75    Warning: reference to possibly unbound identifier `define-record-printer'
     76    Warning:    suggesting: `(import chicken.base)'
     77   
     78    Warning: reference to possibly unbound identifier `URIAuth-port-set!'
     79   
     80    Warning: reference to possibly unbound identifier `URIAuth-port' in:
     81    Warning:    uri-auth->list
     82    Warning:    uri-auth-equal?
     83    Warning:    uri-port
     84    Warning:    update-URIAuth
     85   
     86    Warning: reference to possibly unbound identifier `URIAuth-host-set!'
     87   
     88    Warning: reference to possibly unbound identifier `URIAuth-host' in:
     89    Warning:    uri-auth->list
     90    Warning:    uri-auth-equal?
     91    Warning:    uri-host
     92    Warning:    update-URIAuth
     93   
     94    Warning: reference to possibly unbound identifier `URIAuth-password-set!'
     95   
     96    Warning: reference to possibly unbound identifier `URIAuth-password' in:
     97    Warning:    uri-auth->list
     98    Warning:    uri-auth-equal?
     99    Warning:    uri-password
     100    Warning:    update-URIAuth
     101   
     102    Warning: reference to possibly unbound identifier `URIAuth-username-set!'
     103   
     104    Warning: reference to possibly unbound identifier `URIAuth-username' in:
     105    Warning:    uri-auth->list
     106    Warning:    uri-auth-equal?
     107    Warning:    uri-username
     108    Warning:    update-URIAuth
     109   
     110    Warning: reference to possibly unbound identifier `URIAuth?' in:
     111    Warning:    ucdiff?
     112    Warning:    uri-auth->list
     113   
     114    Warning: reference to possibly unbound identifier `password'
     115   
     116    Warning: reference to possibly unbound identifier `username'
     117   
     118    Warning: reference to possibly unbound identifier `make-URIAuth' in:
     119    Warning:    authority
     120    Warning:    loop
     121   
     122    Warning: reference to possibly unbound identifier `<URIAuth>'
     123   
     124    Warning: reference to possibly unbound identifier `URI-fragment-set!'
     125   
     126    Warning: reference to possibly unbound identifier `URI-fragment' in:
     127    Warning:    uri->list
     128    Warning:    uri-equal?
     129    Warning:    update-uri*
     130    Warning:    update-URI
     131   
     132    Warning: reference to possibly unbound identifier `URI-query-set!'
     133   
     134    Warning: reference to possibly unbound identifier `URI-query' in:
     135    Warning:    uri-relative-to
     136    Warning:    uri->list
     137    Warning:    uri-equal?
     138    Warning:    update-uri*
     139    Warning:    update-URI
     140   
     141    Warning: reference to possibly unbound identifier `URI-path-set!'
     142   
     143    Warning: reference to possibly unbound identifier `URI-path' in:
     144    Warning:    uri-relative-to
     145    Warning:    uri->list
     146    Warning:    uri-equal?
     147    Warning:    update-uri*
     148    Warning:    update-URI
     149   
     150    Warning: reference to possibly unbound identifier `URI-authority-set!'
     151   
     152    Warning: reference to possibly unbound identifier `URI-authority' in:
     153    Warning:    uri-relative-to
     154    Warning:    uri->list
     155    Warning:    uri-equal?
     156    Warning:    loop
     157    Warning:    uri-password
     158    Warning:    uri-username
     159    Warning:    uri-port
     160    Warning:    uri-host
     161    Warning:    update-URI
     162   
     163    Warning: reference to possibly unbound identifier `URI-scheme-set!'
     164   
     165    Warning: reference to possibly unbound identifier `URI-scheme' in:
     166    Warning:    uri-relative-to
     167    Warning:    uri->list
     168    Warning:    uri-equal?
     169    Warning:    update-uri*
     170    Warning:    update-URI
     171   
     172    Warning: reference to possibly unbound identifier `URI?' in:
     173    Warning:    uri->list
     174    Warning:    uri->string
     175   
     176    Warning: reference to possibly unbound identifier `path'
     177   
     178    Warning: reference to possibly unbound identifier `make-URI' in:
     179    Warning:    failure29947
     180    Warning:    relative-ref
     181    Warning:    uri
     182    Warning:    make-uri
     183    Warning:    make-uri*
     184    Warning:    loop
     185   
     186    Warning: reference to possibly unbound identifier `<URI>'
     187   
     188    Warning: reference to possibly unbound identifier `define-record-type'
     189    Warning:    suggesting one of:
     190    Warning:    (import chicken.base)
     191    Warning:    (import srfi-9)
     192   
     193    Warning: reference to possibly unbound identifier `error'
     194    Warning:    suggesting one of:
     195    Warning:    (import chicken.base)
     196    Warning:    (import srfi-23)
     197   
     198    Error: module unresolved: uri-generic
     199
     200This long list looks pretty intimidating, but it's not that hard to
     201fix, actually.  The way to do that is to quickly skim the suggestions.
     202Oftentimes you'll get lots of errors about procedures that don't
     203directly come from missing imports, like in this case (all the
     204URI-blabla procedures being undefined).
     205
     206If you look closely, you'll notice that all of these follow a certain
     207naming pattern: {{URI-foo}} or {{URI-foo-set!}}.  This points us to
     208the fact that they are record accessors.  You'll also notice the
     209suggestion mentioning {{define-record-type}}, which is exactly what we
     210need to import to fix all these errors.
     211
     212Especially when you're using defining macros like you'll see lots of
     213these kinds of errors repeated all over the place where the
     214definitions are used.  So, be aware that this can make the output a
     215bit confusing.  If you have large macros with lots of keywords.
     216That's why it's usually best to start getting your macro imports in
     217order, then recompiling to get rid of all the excess noise.
     218
     219In my example of uri-generic, after adding '''only''' {{(import
     220(chicken base))}}, which I prefer over {{(import chicken.base)}}, the
     221number of warnings/errors were drastically reduced:
     222
     223    Warning: reference to possibly unbound identifier `->string' in:
     224    Warning:    uri-normalize-case
     225    Warning:    suggesting: `(import chicken.string)'
     226   
     227    Warning: reference to possibly unbound identifier `conc'
     228    Warning:    suggesting: `(import chicken.string)'
     229   
     230    Warning: reference to possibly unbound identifier `reverse-list->string' in:
     231    Warning:    uri-char-list->string
     232    Warning:    suggesting: `(import chicken.string)'
     233   
     234    Warning: reference to possibly unbound identifier `string-intersperse' in:
     235    Warning:    join-segments
     236    Warning:    suggesting: `(import chicken.string)'
     237   
     238    Warning: reference to possibly unbound identifier `with-output-to-string' in:
     239    Warning:    uri->string
     240    Warning:    suggesting: `(import chicken.port)'
     241   
     242    Warning: reference to possibly unbound identifier `fprintf'
     243    Warning:    suggesting: `(import chicken.format)'
     244   
     245    Error: module unresolved: uri-generic
     246
     247After adding the suggested imports, the code compiled cleanly and the
     248tests ran without problems, after I fixed a few trivial imports in the
     249test suite.
     250
     251So you see, even for medium sized eggs like uri-generic, porting
     252'''can''' be a breeze.  But beware, there are situations where things
     253can get hairier!
    46254
    47255
Note: See TracChangeset for help on using the changeset viewer.