lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Dec 18, 2013, at 1:07 AM, Sir Pogsalot <sir.pogsalot@gmail.com> wrote:

> (2) Basic signer
> 
> For the record, I wish I could do this -- but my paranoia leads me to distrust tostring() on types I don't "know about".  I mean __tostring might not return a unique representation of the value, or it might return empty-string...  Some odd people out there.

“In __tostring we trust” — Rudolph The Red Nosed Reindeer, head of engineering


> (4) Table signer
> (5) Table identity signer
> 
> Hmm, the only problem I see here is calls like f(1, 2) and f({ 1, 2 }) look the same... :3  I added {} around expanded tables in mine :3

The elves are happy to report that, after extensive testing, no such issue was identified:

“IT WORKS!” — Exclaimed one of the elves, rather surprised

print( Key( TableSigner(), 1, 2 ) )
print( Key( TableSigner(), { 1, 2 } ) )
print( Key( TableSigner( IdentitySigner()  ), 1, 2 ) )
print( Key( TableSigner( IdentitySigner()  ), { 1, 2 } ) )

> 1nu2nu
> 1nu1nu2nu2nuta
> 1.2.
> 1.1.2.2.ta


> Also: Philipp pointed out that for the identity signers it needs to differentiate f(nil) from f() -- I precede the string the call is made into with select('#', ...) and this fixes that :D

Elf #263, head of the testing effort, reported this happy coincidence:

print( 'Signer', ( '%q' ):format( Key( Signer ) ) )
print( 'Signer', ( '%q' ):format( Key( Signer, nil ) ) )
print( 'IdentitySigner', ( '%q' ):format( Key( IdentitySigner() ) ) )
print( 'IdentitySigner', ( '%q' ):format( Key( IdentitySigner(), nil ) ) )
print( 'TableSigner', ( '%q' ):format( Key( TableSigner() ) ) )
print( 'TableSigner', ( '%q' ):format( Key( TableSigner(), nil ) ) )
print( 'TableIdentitySigner', ( '%q' ):format( Key( TableSigner( IdentitySigner() ) ) ) )
print( 'TableIdentitySigner', ( '%q' ):format( Key( TableSigner( IdentitySigner() ), nil ) ) )

> Signer	"”
> Signer	"ni”
> IdentitySigner	"”
> IdentitySigner	"0.”
> TableSigner	"”
> TableSigner	"ni”
> TableIdentitySigner	"”
> TableIdentitySigner	"0."