<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi Levente,<div><br></div><div>I agree. There are only like 40 uses if such explicit symbol lookup. In most cases #asSymbol or the use of strings works just fine. No need to expand the Symbol interface here.</div><div><br></div><div>+1 for #lookupSymbol</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 12.07.2019 00:31:57 schrieb Levente Uzonyi <leves@caesar.elte.hu>:</p><div style="font-family:Arial,Helvetica,sans-serif">Hi Marcel,
<br>
<br>I see no problem with ifNotNil: here.
<br>If I wanted to create a simpler API, I'd implement something like this:
<br>
<br>String >> #lookupSymbol
<br>
<br> ^Symbol lookup: self
<br>
<br>Then I could write
<br>
<br> 'foo' lookupSymbol ifNotNil: [ :fooSymbol | ... ]
<br>
<br>instead of
<br>
<br> (Symbol lookup: 'foo') ifNotNil: [ :fooSymbol | ... ]
<br>
<br>or
<br>
<br> Symbol lookup: 'foo' ifFound: [ :fooSymbol | ... ]
<br>
<br>But given how rarely symbol lookups happen in practice, I'd keep things
<br>simple and fast.
<br>
<br>Levente
<br>
<br>On Thu, 11 Jul 2019, Marcel Taeumel wrote:
<br>
<br>> I put a proposal in the inbox: Collections-mt.840
<br>> Best,
<br>> Marcel
<br>>
<br>> Am 11.07.2019 12:41:06 schrieb Marcel Taeumel <marcel.taeumel@hpi.de>:
<br>>
<br>> What about adding #lookup:ifFound:?
<br>>
<br>> Am 11.07.2019 11:47:37 schrieb Marcel Taeumel <marcel.taeumel@hpi.de>:
<br>>
<br>> Hi Levente,
<br>> hmmm... yet, the "ifNil:"-check needed for #lookup: impedes readability in my opinion. :-)
<br>>
<br>> Best,
<br>> Marcel
<br>>
<br>> Am 11.07.2019 11:02:13 schrieb Levente Uzonyi <leves@caesar.elte.hu>:
<br>>
<br>> Hi Marcel,
<br>>
<br>> These changes should go the other way around. #hasInterned:ifTrue: is
<br>> private and more specific. #lookup: is more general (#hasInterned:ifTrue:
<br>> uses lookup) and faster.
<br>> In my opinion, #hasInterned:ifTrue: should be deprecated, then removed.
<br>>
<br>> Levente
<br>>
<br>> On Thu, 11 Jul 2019, commits@source.squeak.org wrote:
<br>>
<br>> > Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
<br>> > http://source.squeak.org/trunk/Morphic-mt.1491.mcz
<br>> >
<br>> > ==================== Summary ====================
<br>> >
<br>> > Name: Morphic-mt.1491
<br>> > Author: mt
<br>> > Time: 11 July 2019, 7:43:26.133838 am
<br>> > UUID: 8e7d61cb-067a-d145-a86e-3484bfb38617
<br>> > Ancestors: Morphic-cmfcmf.1490
<br>> >
<br>> > Replaces one use of Symbol class >> #lookup: with the more common (i.e., more senders) idiom Symbol class >> #hasInterned:ifTrue:.
<br>> >
<br>> > =============== Diff against Morphic-cmfcmf.1490 ===============
<br>> >
<br>> > Item was changed:
<br>> > ----- Method: SearchBar>>smartSearch:in: (in category 'searching') -----
<br>> > smartSearch: text in: morph
<br>> > "Take the user input and perform an appropriate search"
<br>> > | input newContents |
<br>> > self removeResultsWidget.
<br>> > input := text asString ifEmpty:[^self].
<br>> > self class useSmartSearch ifFalse: [^ ToolSet default browseMessageNames: input].
<br>> >
<br>> > "If it is a global or a full class name, browse that class."
<br>> > (Smalltalk bindingOf: input) ifNotNil:[:assoc| | global |
<br>> > global := assoc value.
<br>> > ^ToolSet browse: (global isBehavior ifTrue:[global] ifFalse:[global class]) selector: nil].
<br>> >
<br>> > "If it is a symbol and there are implementors of it, browse those implementors."
<br>> > + Symbol hasInterned: input ifTrue: [:selector |
<br>> > - (Symbol lookup: input) ifNotNil: [:selector |
<br>> > (SystemNavigation new allImplementorsOf: selector) ifNotEmpty:[:list|
<br>> > ^SystemNavigation new
<br>> > browseMessageList: list
<br>> > name: 'Implementors of ' , input]].
<br>> >
<br>> > "If it starts uppercase, browse classes if any. Otherwise, just search for messages."
<br>> > input first isUppercase
<br>> > ifTrue: [
<br>> > (UIManager default classFromPattern: input withCaption: '')
<br>> > ifNotNil:[:aClass| ^ToolSet browse: aClass selector: nil]
<br>> > ifNil: [
<br>> > newContents := input, ' -- not found.'.
<br>> > self searchTerm: newContents.
<br>> > self selection: (input size+1 to: newContents size).
<br>> > self currentHand newKeyboardFocus: morph textMorph.
<br>> > ^ self]]
<br>> > ifFalse: [
<br>> > ToolSet default browseMessageNames: input].!
<br>>
<br>>
<br>><br></leves@caesar.elte.hu></marcel.taeumel@hpi.de></marcel.taeumel@hpi.de></div></blockquote>
</div></body>