[Vm-dev] Push/pop considered harmful

Igor Stasenko siguctua at gmail.com
Tue Mar 3 19:32:25 UTC 2009


I was thinking about making an argument count check mandatory,
so VMMaker could spit in your face when you forget adding it.
One of the ways could be to make
self expectedNumArgs: 0
as a slang directive, which extracts the number and builds a primitive
table with entries of 2 elements:
- function pointer
- expected arguments.

Then we could check the number of arguments before calling a primitive
function and fail even without calling it. Moreover we don't need to
worry that someone forget adding #expectedNumArgs: in his code,
because its mandatory.

2009/3/3 John M McIntosh <johnmci at smalltalkconsulting.com>:
>
> well we also have
>
>        self primitive: 'primitiveCreateHostWindow'
>                parameters: #(SmallInteger SmallInteger SmallInteger
> SmallInteger ByteArray).
>
> So I'm wondering here how many ways do we want to achieve the same thing.
> Most people wanting to build a plugin want something that doesn't require
> too much thinking,
> then again very few people build plugins, but in the code about, well we
> know it should have 5 parms
> However the construct doesn't handle the case of expectedNumArgsBetween: 0
> and: 3
>
>
> On 3-Mar-09, at 10:59 AM, Eliot Miranda wrote:
>
>>
>>
>> self expectedNumArgs: 0
>>    => self only
>> self expectedNumArgs: 1
>>    => self plus one argument
>> self expectedNumArgsBetween: m and: n
>>    for var-args primitives like perform:[with:*] and value[:[value:*]]
>>
>> Perhaps checkNumArgs: or failUnlessNumArgs: are better names?
>>
>
> - Show quoted text -
> --
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list