I don't fully understand your C++ example, but

FUNCTOR: test1 ( NAME -- ) NAME IS ${NAME} WHERE TUPLE: NAME ; ;FUNCTOR
does create the tuple, but now when the functor is parsed. It's when
the functor is called (in the following example, you can call the
functor directly instead of using the SYNTAX; ..  with $[ toto test1 ]
or [ toto test1 ] with-compilation-unit, but I think the standard way
is to use SYNTAX: ... )

For example, with the following two files :
USING: functors kernel io lexer ;
IN: funtest.functor
FUNCTOR: test1 ( NAME -- ) NAME IS ${NAME} WHERE TUPLE: NAME ; ;FUNCTOR
SYNTAX: TEST1: scan test1 ;

USING: funtest.functor ;
IN: funtest
SYMBOL: toto
TEST1: toto

In the listener,
( scratchpad ) toto tuple-class? .
t ! toto is no longer a symbol, it's now a class


>From what I understand, the QList<T> word doesn't exist yet so you
shouldn't use IS, but DEFINES. However, I don't understand the
difference between DEFINES and DEFINES-CLASS, since the TUPLE: clause
in the body of the functor creates the class predicate anyway.

Good luck

On Thu, May 27, 2010 at 12:25 PM, Jeremy Hughes <[email protected]> wrote:
> The functor appended to the mail isn't working! :-)
>
> It's intended use is for template classes in the C++ ffi. MEMBERS:
> expects an existing c-type and ;MEMBERS compiles and links the generated
> code. The rest should be fairly obvious.
>
> The problem is that when the vocabulary is parsed, MEMBERS: onward are
> executed and fail because QList<T> is not a valid c-type.
>
> execute-parsing is invoked in parse-step, but afaict that's no different
> with words like TUPLE:. The following FUNCTOR doesn't create a NAME
> tuple when parsed.
>
> FUNCTOR: test1 ( NAME -- ) NAME IS ${NAME} WHERE TUPLE: NAME ; ;FUNCTOR
>
> Where am I going wrong?
>
> Cheers,
> Jeremy
>
>
> FUNCTOR: QList ( T -- )
>
> T IS ${T}
> QList<T> IS QList<${T}>
> <QList(T)> DEFINES <QList(${T})>
> <QList(T)-copy> DEFINES <QList(${T})-copy>
>
> WHERE
>
> MEMBERS: QList<T>
>
> C-INCLUDE: <Qt/QList>
> C-LINK/FRAMEWORK: QtCore
>
> CTOR: <QList(T)> ( )
>
> ALIAS-M++ suffix!
>     void append ( T value )
>
> M++ T& back ( )
> M++ void clear ( )
> M++ int count ( )
> M++ bool isEmpty ( )
>
> ;MEMBERS
>
> ;FUNCTOR
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------

_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to