On Friday, August 12, 2016 at 11:54:21 AM UTC-7, Julian Fondren wrote:
> * Forth Inc. just wants you to buy SwiftForth.
> * SwiftForth comes with SWOOP , providing structures and more.
> * Forth Inc. are opposed to structures.
>
> Man it's really difficult sometimes to get your malicious
> characterizations to agree with your analyses of sinister plots.
SWOOP is only available under SwiftForth (hence the name), and SwiftForth costs money. Forth Inc. is opposed to structs (such as used in my novice package) because they are selling SWOOP as the only way to obtain structs.
Lets compare SWOOP with my novice-package method. Here is a super-simple example (no inheritance, no cloning, no pointers to other structs in the struct, etc.):
------------------------------------------------------------------------
marker swoop.4th
\ this is SWOOP
class point
variable x
variable y
: show ( -- ) x @ . y @ . ;
: dot ( -- ) ." Point at " show ;
end-class
: test ( -- )
point new >r
5 r@ using point x !
8 r@ using point y !
r@ using point dot
r@ using point destroy
rdrop ;
\ this is my method
0
w field .x
w field .y
constant pnt
: init-pnt ( x y node -- node )
>r
r@ .y !
r@ .x !
r> ;
: new-pnt ( x y -- node )
pnt alloc
init-pnt ;
: kill-pnt ( node -- )
dealloc ;
: show-pnt ( node -- )
>r
cr ." X: " r@ .x ?
cr ." Y: " r@ .y ?
rdrop ;
: my-test ( -- )
5 8 new-pnt >r
r@ show-pnt
r@ kill-pnt
rdrop ;
------------------------------------------------------------------------
I think my code is much more readable that the SWOOP code. Anybody using POINT in SWOOP is going to get tired of writing
USING POINT
The only problem with my method is that I don't have polymorphism. You can't have other structs with fields called .X and .Y etc.. This is easy to solve though --- just call your fields PNT.X and PNT.Y etc.. --- this bloats out the source-code somewhat (it is like USING POINT except not as bad), but it is reasonable in a large program that uses a lot of different structs.
Here is a start on disassembling MY-TEST:
see my-test
491CAF 8 # EBP SUB 83ED08
491CB2 EBX 4 [EBP] MOV 895D04
491CB5 5 # 0 [EBP] MOV C7450005000000
491CBC 8 # EBX MOV BB08000000
491CC1 491BEF ( new-pnt ) CALL E829FFFFFF
491CC6 EBX PUSH 53
491CC7 491C3F ( show-pnt ) CALL E873FFFFFF
491CCC 4 # EBP SUB 83ED04
491CCF EBX 0 [EBP] MOV 895D00
491CD2 0 [ESP] EBX MOV 8B1C24
491CD5 480CDF ( dealloc ) CALL E805F0FEFF
491CDA EAX POP 58
491CDB RET C3 ok
see new-pnt
491BEF 4 # EBP SUB 83ED04
491BF2 EBX 0 [EBP] MOV 895D00
491BF5 8 # EBX MOV BB08000000
491BFA 480C8F ( alloc ) CALL E890F0FEFF
491BFF 491BAF ( init-pnt ) JMP E9ABFFFFFF ok
see init-pnt
491BAF EBX PUSH 53
491BB0 4 # EBX ADD 83C304
491BB3 0 [EBP] EAX MOV 8B4500
491BB6 EAX 0 [EBX] MOV 8903
491BB8 4 [EBP] EBX MOV 8B5D04
491BBB 8 # EBP ADD 83C508
491BBE 4 # EBP SUB 83ED04
491BC1 EBX 0 [EBP] MOV 895D00
491BC4 0 [ESP] EBX MOV 8B1C24
491BC7 0 [EBP] EAX MOV 8B4500
491BCA EAX 0 [EBX] MOV 8903
491BCC EBX POP 5B
491BCD 4 # EBP ADD 83C504
491BD0 RET C3 ok
I would estimate the speed of SWOOP to be one or two orders of magnitude slower than the speed of my code. Realistically, nobody is ever going to use SWOOP for any program in which speed matters at all. Using simple code such as I have in the novice-package, SwiftForth is about 1/4 the speed necessary for commercial programming and would only be usable for programs that don't really have any speed requirements (possibly those that spend all of their time waiting for user input).
Here is just a start on disassembling TEST however. I can't figure out what BROADCAST does because SEE can't find it, but it may be a whopper. I also can't figure out what the code in POINT does because SEE doesn't work on it either. I think my estimate of one or two orders of magnitude slower than my code is reasonable however.
see test
491A8F 49198F ( point ) CALL E8FBFEFFFF
491A94 426F9F ( NEW ) CALL E80655F9FF
491A99 EBX PUSH 53
491A9A 5 # EBX MOV BB05000000
491A9F 4 # EBP SUB 83ED04
491AA2 EBX 0 [EBP] MOV 895D00
491AA5 0 [ESP] EBX MOV 8B1C24
491AA8 0 [EBP] EAX MOV 8B4500
491AAB EAX 0 [EBX] MOV 8903
491AAD 4 [EBP] EBX MOV 8B5D04
491AB0 8 # EBP ADD 83C508
491AB3 4 # EBP SUB 83ED04
491AB6 EBX 0 [EBP] MOV 895D00
491AB9 8 # EBX MOV BB08000000
491ABE 4 # EBP SUB 83ED04
491AC1 EBX 0 [EBP] MOV 895D00
491AC4 0 [ESP] EBX MOV 8B1C24
491AC7 4 # EBX ADD 83C304
491ACA 0 [EBP] EAX MOV 8B4500
491ACD EAX 0 [EBX] MOV 8903
491ACF 4 [EBP] EBX MOV 8B5D04
491AD2 8 # EBP ADD 83C508
491AD5 4 # EBP SUB 83ED04
491AD8 EBX 0 [EBP] MOV 895D00
491ADB 0 [ESP] EBX MOV 8B1C24
491ADE A8 [ESI] PUSH FFB6A8000000
491AE4 EBX A8 [ESI] MOV 899EA8000000
491AEA 0 [EBP] EBX MOV 8B5D00
491AED 4 # EBP ADD 83C504
491AF0 A4 [ESI] PUSH FFB6A4000000
491AF6 8D98F # A4 [ESI] MOV C786A40000008FD90800
491B00 491A59 ( point +CA ) CALL E854FFFFFF
491B05 A4 [ESI] POP 8F86A4000000
491B0B A8 [ESI] POP 8F86A8000000
491B11 4 # EBP SUB 83ED04
491B14 EBX 0 [EBP] MOV 895D00
491B17 0 [ESP] EBX MOV 8B1C24
491B1A 42701F ( DESTROY ) CALL E80055F9FF
491B1F EAX POP 58
491B20 RET C3 ok
see new
426F9F 4 # EBP SUB 83ED04
426FA2 EBX 0 [EBP] MOV 895D00
426FA5 42585F ( SIZEOF ) CALL E8B5E8FFFF
426FAA 8 # EBX ADD 83C308
426FAD 40A15F ( ALLOCATE ) CALL E8AD31FEFF
426FB2 4054AF ( THROW ) CALL E8F8E4FDFF
426FB7 4 # EBP SUB 83ED04
426FBA EBX 0 [EBP] MOV 895D00
426FBD 2159F # EBX MOV BB9F150200
426FC2 EBX EAX MOV 8BC3
426FC4 0 [EBP] EBX MOV 8B5D00
426FC7 4 # EBP ADD 83C504
426FCA EAX 0 [EBX] MOV 8903
426FCC 4 # EBX ADD 83C304
426FCF 4 # EBP SUB 83ED04
426FD2 EBX 0 [EBP] MOV 895D00
426FD5 4 [EBP] EBX MOV 8B5D04
426FD8 EBX EAX MOV 8BC3
426FDA 0 [EBP] EBX MOV 8B5D00
426FDD 4 # EBP ADD 83C504
426FE0 EAX 0 [EBX] MOV 8903
426FE2 4 # EBX ADD 83C304
426FE5 0 [EBP] EAX MOV 8B4500
426FE8 4 # EBP SUB 83ED04
426FEB EBX 4 [EBP] MOV 895D04
426FEE EAX 0 [EBP] MOV 894500
426FF1 4 # EBP SUB 83ED04
426FF4 EBX 0 [EBP] MOV 895D00
426FF7 22CCF # EBX MOV BBCF2C0200
426FFC 426DBF ( BROADCAST ) JMP E9BEFDFFFF ok
see destroy
42701F 4 # EBP SUB 83ED04
427022 EBX 0 [EBP] MOV 895D00
427025 4 # EBX SUB 83EB04
427028 0 [EBX] EBX MOV 8B1B
42702A 4 # EBP SUB 83ED04
42702D EBX 0 [EBP] MOV 895D00
427030 4 [EBP] EBX MOV 8B5D04
427033 4 # EBP SUB 83ED04
427036 EBX 0 [EBP] MOV 895D00
427039 22CEF # EBX MOV BBEF2C0200
42703E 426DBF ( BROADCAST ) CALL E87CFDFFFF
427043 4 # EBX SUB 83EB04
427046 4 # EBX SUB 83EB04
427049 40A19F ( FREE ) CALL E85131FEFF
42704E 4054AF ( THROW ) JMP E95CE4FDFF ok