Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Blatantly stolen from tutorial page
- type
- TSocket* = object of TObject
- FHost: int # cannot be accessed from the outside of the module
- # the `F` prefix is a convention to avoid clashes since
- # the accessors are named `host`
- TNewSockObj = object of TSocket
- FNewHost: int
- # To define new setter for 'TNewSockObj' that would take object and int as param
- # and set 'FHost' and 'FNewHost' to the int, could I do:
- proc `host=`*(s: var TNewSockObj, value: int) {.inline.}=
- s.FHost = value
- s.FNewHost = value
- # or would I have to redefine both setters as methods?
- # Originals:
- proc `host=`*(s: var TSocket, value: int) {.inline.} =
- ## setter of hostAddr
- s.FHost = value
- proc host*(s: TSocket): int {.inline.} =
- ## getter of hostAddr
- s.FHost
- var
- s: TSocket
- s.host = 34 # same as `host=`(s, 34)
Advertisement
Add Comment
Please, Sign In to add comment