[Critical] Bug with lambdas!

Bug reports for the stable versions go here.
Post Reply
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Ran into this while working on TSB
Eventually this placeholder lambda is going to be replaced with something that works, and any game started with a placeholder version wont work correctly once it is updated


Image

Code: Select all

[09:05:06]	Avan	basically
[09:05:13]	Avan	the first two calls to gCriteriaLambda
[09:05:18]	Avan	should give insufficient argument errors
[09:05:23]	Avan	the third should return true
[09:05:35]	Avan	but isntead its acting as if i called something that was not a function as a function
[09:05:39]	Avan	(like where i call the list
[09:05:46]	Avan	yet it clearly stores the lambda in itself
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I'd like to see the code that assigns the lambda. It looks like it is assigned to a literal list, not an expression. In particular, you shouldn't use the quote (') syntax when returning a list from TSB_shpGetDeviceSlot. I think the (list ...) expression will work better.

Either way, though, I'd like to see the code inside TSB_shpGetDeviceSlot that returns the list.
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

I dont use '(a b c) to assign lists, i only use (list a b c)


Code: Select all

					;;left slot
					(TSB_shpDefineDeviceSlot
						gSource
						'Left
						7
						70
						0
						Nil
						True
						-20
						170
						'whenInFireArc
						Nil
						(list "w^I -Howitzer" TSB_raptorSecondarySlots)
					)

Setting the list

Code: Select all

		(setq TSB_shpDefineDeviceSlot (lambda (object slotName posRadius posAngle posZ omniTF pivotTF fireArcMin fireArcMax LinkedFireOption secondaryTF critereonList)
			(block (slotList)
				(setq slotList (objGetData object 'TSB_slotManagerDeviceSlotList))
				(if (eq Nil slotList) (setq slotList (list)))
				(lnkAppend slotList (list slotName posRadius posAngle posZ omniTF pivotTF fireArcMin fireArcMax LinkedFireOption secondaryTF critereonList Nil))
				(objSetData object 'TSB_slotManagerDeviceSlotList slotList)
			)
		));;setq and lambda
Retreiving the list

Code: Select all

		(setq TSB_shpGetDeviceSlot (lambda (object slotName)
			(block (slotList slot)
				(setq slot Nil)
				(setq slotList (objGetData object 'TSB_slotManagerDeviceSlotList))
				(if (eq Nil slotList)
					(block Nil (setq slotList (list)) (setq slot Nil))
					(enumWhile slotList (eq slot Nil) curSlot
						(if (eq (item curSlot 0) slotName) (setq slot curSlot))
					)
				)
				slot
			)
		));;setq and lambda
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
Post Reply