tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Improve documentation on value-type and assert-concept #92

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

value-type only works inside of assert-concept, but I need to use the value-type somewhere else, but value-type is not in scope (see here: https://github.com/porky11/planets/blob/129c4e9d9d49f53891df7d25668ce58e3e4c21b4/src/sequence-math.dt#L87)

tomhrr commented 8 years ago

On Sun, Sep 11, 2016 at 02:24:54AM -0700, Fabio Krapohl wrote:

value-type only works inside of assert-concept, but I need to use the value-type somewhere else, but value-type is not in scope (see here: https://github.com/porky11/planets/blob/129c4e9d9d49f53891df7d25668ce58e3e4c21b4/src/sequence-math.dt#L87)

It's not that it only works within assert-concept, but that assert-concept wraps the 'implements' argument expression with a quasiquotation form. Something like the following:

(def-concept-macro / extern ((T Container))
  (let ((val-type \ (value-type (nullptr (uq T)))))
    (assert-concept val-type Divable))
  (using-namespace std.macros
    (qq do
    ...

will report a 'not in scope' error, because '(uq T)' doesn't make sense outside of a '(qq ...)' form. Repeating the 'value-type' call is probably the easiest way to make this work as expected.

porky11 commented 8 years ago

Thanks, easier than I thought