[squeak-dev] The Inbox: Compiler-mt.436.mcz

K K Subbu kksubbu.ml at gmail.com
Fri Jun 12 11:22:49 UTC 2020

On 12/06/20 7:44 am, commits at source.squeak.org wrote:
> + ----- Method: Parser>>primitive (in category 'primitives') -----
> + primitive
> + 	"Pragmas that encode primitive calls are parsed as normal keyword pragmas. This hook exists so that packages do not break primitive-pragma parsing by accident. Instead, this method needs to be replaced intentionally.
> + 	
> + 	Note that primitive pragmas are special because they will be called back from the parser into the parser. See #pragmaPrimitives.
> + 	
> + 	Examples:
> + 		<primitive: 42>
> + 		<primitive: 'primitiveDirectoryCreate' module: 'FilePlugin'>
> + 		<primitive: 'primitiveRegisterExternalFill' module: 'B2DPlugin' error: errorCode>"
> +
> + 	<pragmaParser>

Why should the parser treat primitive keywords differently from other 
keywords? Why not let primitives also be handled like any other pragma 
and have the handler return a flag to let the parser treat the pragma as 
a primitive/nonprimitive?

It just occurred to me (strawman alert!) that the parser could parse
    <primitive: 42>
    <primitive: 'prim42' module: 'primitivePlugin'>

It will allow us to switch primitive tables at run time without 
recompiling the VM.

Regards .. Subbu

More information about the Squeak-dev mailing list