Paste: old vs new initialization

Author: erg
Mode: factor
Date: Fri, 12 Jun 2009 17:19:44
Plain Text |
TUPLE: threaded-server
name
log-level
secure insecure
secure-config
sockets
max-connections
semaphore
timeout
encoding
handler
ready ;

: new-threaded-server ( encoding class -- threaded-server )
   new
       swap >>encoding
       "server" >>name
       DEBUG >>log-level
       1 minutes >>timeout
       V{ } clone >>sockets
       <secure-config> >>secure-config
       [ "No handler quotation" throw ] >>handler
       <flag> >>ready ; inline

TUPLE: managed-server < threaded-server clients ;

: new-managed-server ( port name encoding class -- server )
   new-threaded-server
       swap >>name
       swap >>insecure
       f >>timeout
       H{ } clone >>clients ; inline

TUPLE: chat-server < managed-server ;

: <chat-server> ( port -- managed-server )
    "chat-server" utf8 chat-server new-managed-server ;

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


TUPLE: threaded-server
{ name initial: "server" }
{ log-level initial: DEBUG }
secure
insecure
{ secure-config initial-quot: [ <secure-config> ] }
{ sockets initial-quot: [ V{ } clone ] }
max-connections
semaphore
{ timeout initial-quot: [ 1 minutes ] }
encoding
{ handler initial: [ "No handler quotation" throw ] }
{ ready initial-quot: [ <flag> ] } ;

CONSTRUCTOR: threaded-server ( encoding -- obj ) ;


TUPLE: managed-server < threaded-server
{ clients initial-quot: [ H{ } clone ] }
{ timeout initial: f } ;

CONSTRUCTOR: managed-server ( insecure name encoding -- server ) ;


TUPLE: chat-server < managed-server
{ name initial: "chat-server" }
{ encoding initial: utf8 } ;

CONSTRUCTOR: chat-server ( insecure -- obj ) ;

New Annotation

Summary:
Author:
Mode:
Body: