Paste: Getting an error I don't understand

Author: Erich Ocean
Mode: factor
Date: Sat, 21 May 2011 07:51:27
Plain Text |
: <namespace> ( -- namespace )
    H{ } clone ;

VALUE: App
<namespace> App set-value

SYMBOLS: picker-view layout mouse-down ;

: add-property ( variable value -- )
    swap set ;

ALIAS: add-responder-method add-property

App [ picker-view

<view>
    layout { 100 100 10 50 } add-property
    mouse-down [| evt | drop beep t ] add-responder-method

swap set ] bind

! ERROR: Generic word def>> does not define a method for the POSTPONE: f class.

Annotation: Improved version

Author: Erich Ocean
Mode: factor
Date: Sat, 21 May 2011 08:03:41
Plain Text |
! defining new instances in a namespace in the global scope
: <namespace> ( -- namespace )
    H{ } clone ;

VALUE: App
<namespace> App set-value

SYMBOLS: picker-view layout mouse-down ;

: add-property ( variable value -- )
    swap set ;

ALIAS: add-responder-method add-property

:: define-instance ( ns var value -- )
    ns [ value var set ] bind ;

App picker-view <view>

    layout { 100 100 10 50 } add-property
    mouse-down [| evt | drop beep t ] add-responder-method

define-instance

! ERROR: Generic word def>> does not define a method for the POSTPONE: f class.

Annotation: corrected version

Author: Erich Ocean
Mode: factor
Date: Sat, 21 May 2011 19:22:00
Plain Text |
! defining new instances in a namespace in the global scope
: <namespace> ( -- namespace )
    H{ } clone ;

VALUE: App
<namespace> \ App set-value

SYMBOLS: PickerView picker-view my-layout my-mouse-down ;

: add-property ( variable value -- )
    swap set ;

ALIAS: add-responder-method add-property

:: define-instance ( ns var value -- )
    ns [ value var set ] bind ;

: <view> ( -- view )
    <namespace> ;

: create ( ns -- ns )
    dup >n ;

! : create ( namespace -- )

App picker-view <view> create

    my-layout { 100 100 10 50 } add-property
    my-mouse-down [| evt | drop beep t ] add-responder-method

define-instance

New Annotation

Summary:
Author:
Mode:
Body: