[squeak-dev] The Trunk: ShoutCore-mt.81.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Mon Jun 15 17:19:28 UTC 2020


Hi Levente.

> How about using #hasPragma: here?

Now we have a first use of it in Trunk. :-D




Best,
Marcel
Am 15.06.2020 18:22:27 schrieb Levente Uzonyi <leves at caesar.elte.hu>:
Hi Marcel,

On Mon, 15 Jun 2020, commits at source.squeak.org wrote:

> Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
> http://source.squeak.org/trunk/ShoutCore-mt.81.mcz
>
> ==================== Summary ====================
>
> Name: ShoutCore-mt.81
> Author: mt
> Time: 15 June 2020, 4:41:07.031209 pm
> UUID: b5dfda57-678c-bd4b-91ba-3eae94326352
> Ancestors: ShoutCore-mt.80
>
> Avoid breaking new hook for when subclassing SHParserST80. That is, re-use all existing pragma parsers automatically in subclasses. Note that #methodDict was chosen over #lookupSelector: for performance reasons.

I think it would be worth adding a few test cases custom pragma parsers.

>
> =============== Diff against ShoutCore-mt.80 ===============
>
> Item was changed:
> ----- Method: SHParserST80>>parsePragmaStatement (in category 'parse pragma') -----
> parsePragmaStatement
>
> | parserSelector |
> (currentToken last == $:
> and: [(parserSelector := Symbol lookup: currentToken allButLast) notNil])
> ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
> ^ self parsePragmaStatementKeywords].

I think it would be easier to read the above lines in the following form:

currentToken last == $: ifTrue: [
(Symbol lookup: currentToken allButLast) ifNotNil: [ :parserSelector |
"Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
^self parsePragmaStatementKeywords ] ].

>
> + SHParserST80 methodDict
> - self class methodDict
> at: parserSelector
> ifPresent: [:parserMethod |
> (parserMethod pragmas
> anySatisfy: [:pragma | pragma keyword == #pragmaParser])
> ifTrue: [^ self executeMethod: parserMethod]].

How about using #hasPragma: here?

(parserMethod hasPragma: #pragmaParser) ifTrue: [
^self executeMethod: parserMethod ]


Levente

>
> ^ self parsePragmaStatementKeywords!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200615/faa14489/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 47558 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200615/faa14489/attachment-0001.png>


More information about the Squeak-dev mailing list