[Cryptography Team] [Vm-dev] Smalltalk code calling SHA2Plugin

Robert Withers robert.withers at pm.me
Tue Jul 21 19:37:37 UTC 2020


Erg, I meant "Hi Levente", of course. It there an exception to mark deprecated and suggest alternate code to use?

K, r

On 7/21/20 3:22 PM, Robert wrote:

> Hub Levente,
>
> I like the idea of SHA256 and friends to throw an exception when #new is called directly
> SHA256 new.
> With a message to call newSHA256.
>
> What do you think?
>
> Kindly,
> Robert
>
> On Tue, Jul 21, 2020 at 14:02, Levente Uzonyi <leves at caesar.elte.hu> wrote:
>
>> Hi Chris,
>>
>> On Mon, 20 Jul 2020, Chris Muller wrote:
>>
>>> Hi Levente,
>>>
>>> > > HashFunction newSHA256
>>> > >
>>> > > instead of
>>> > >
>>> > > SHA256 new
>>> > >
>>> > > in order to take advantage of Levente's plugin.
>>> >
>>> > That is indeed some sort of a change but it only affects those who
>>> > compiled the SHA256Plugin themselves since that plugin wasn't shipped with
>>> > the VM.
>>>
>>> Ah, you're speaking about legacy code. I really hope we can include your plugin in future VM's. Are Eliot, et al, on board?
>>
>> The most recent VMs ship with the plugins.
>>
>>> > I decided against the practice of making #new return an instance of
>>> > another class than the receiver, as it was with the previous
>>> > implementation, because that makes it a lot harder for others to
>>> > understand the code.
>>>
>>> Hm. I sort of agree, although I guess Factory is a recognized pattern. To me, the issue is that writing
>>>
>>> "SHA256 new"
>>>
>>> , is a perfectly intuitive and obvious way to use it, but sticking out like a sore thumb as a subversively-wrong-way to-use-it. It'd be better if it threw an error, and even better than that if it just worked.
>>>
>>> I know you care about the quantity of methods in the image (as do I), how about quality? Can SHA256 #new be improved by doing essentially what HashFunction #newSHA256 does, and simply sending some alternative to new (i.e.,
>>
>> It's not clear what do you mean by caring about the quantity of methods.
>>
>>> basicNew initialize) to avoid the recursion?
>>
>> That would do exactly what I do not want to do: #new would return an
>> object whose class is not SHA256.
>>
>>>
>>> Above, you mentioned you decided against the practice, does that mean you're writing:
>>>
>>> SHA256 newSHA256
>>>
>>> ? If not, how did you do it?
>>
>> Use HashFunction's class side #new* methods to create the instances.
>> HashFunction is a facade and a factory at the same time.
>> I originally wanted to create a separate class for this role named Hasher,
>> but HashFunction seemed to work just as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/cryptography/attachments/20200721/7665eec4/attachment.html>


More information about the Cryptography mailing list