Search with "Whole words only" option should omit @

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Search with "Whole words only" option should omit @

Post by uwekel »

Hi,

when searching with the option "Whole words only", function adresses with a @ prefix will not be included in the search results. This is inconvenient when you want to search or replace a function name. The search should omit the @ character from the word characters list.

Best regards
Uwe
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

uwekel wrote:The search should omit the @ character from the word characters list.
Yes, it should.
And the asterisk character (*) has the same problem, already reported a long time ago.

That's why I do not search for whole words in the IDE anymore, it's just unreliable.
Since I realized this problem, I'm using a third party editor for this purpose. :(
That shouldn't be necessary.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Search with "Whole words only" option should omit @

Post by PB »

Well, the @ and * are part of the "word", so just include them. No biggie.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

PB wrote:Well, the @ and * are part of the "word", so just include them. No biggie.
I would also like the world to be that simple ... :-) Unfortunately, this is not the case.
You might want to read the thread to which I posted the link in my previous post, and then reconsider your statement.
if you include @ or * in the word you are searching for, then the search will not find the respective word without @ or *.

In other words, when I want to reliably search and replace a variable or procedure name, I'll have to do 3 search and replace operations:
- one with identifier
- one with @identifier
- one with *identifier

Not exactly a satisfying solution.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Search with "Whole words only" option should omit @

Post by PB »

> if you include @ or * in the word you are searching for,
> then the search will not find the respective word without @ or *

That's right and perfectly logical, because @ and * are PART OF THE NAME.
Just because those chars are not letters, doesn't mean they can be ignored.

> when I want to reliably search and replace a variable or procedure name,
> I'll have to do 3 search and replace operations

Yep, because you have 3 different and distinct objects (var, pointer, procedure).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Search with "Whole words only" option should omit @

Post by uwekel »

PB, i agree with the asterix *, but the @ is just an address operator to the following attached variable or function.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Search with "Whole words only" option should omit @

Post by TI-994A »

PB wrote:...@ and * are PART OF THE NAME...

...3 different and distinct objects (var, pointer, procedure).
Hi PB. With all due respect, the @ is technically not part of the variable or procedure name. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

uwekel wrote:PB, i agree with the asterix * [...]
Unfortunately, I can not agree:

Code: Select all

a=3
b=4
Debug a*b
TI-994A wrote:the @ is technically not part of the variable or procedure name. :D
Agreed.

Obviously, both * and @ are not (necessarily) part of an identifier name.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Search with "Whole words only" option should omit @

Post by uwekel »

I meant if the asterix belongs to a pointer variable.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

uwekel wrote:I meant if the asterix belongs to a pointer variable.
Yes, of course. :-) I know.

Humans and the compiler can make this distinction.
But the search function of the IDE doesn't know whether an asterisk belongs to a pointer variable, or whether it means "multiply".
That's part of the problem.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Search with "Whole words only" option should omit @

Post by PB »

BTW, the only reason I'm opposed to this, is because it may
lead to something getting replaced that shouldn't. When you
include the @ or * then this risk is totally removed.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

PB wrote:it may lead to something getting replaced that shouldn't.
What, for instance?
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Search with "Whole words only" option should omit @

Post by TI-994A »

Little John wrote:...both * and @ are not (necessarily) part of an identifier name.
Little John wrote:...the search function of the IDE doesn't know whether an asterisk belongs to a pointer variable, or whether it means "multiply"...
Operators and address references never form any part of an identifier. But insofar as the search & replace is concerned, perhaps. That is why best practices recommend leaving spaces between variables and operators. :)
PB wrote:...When you include the @ or * then this risk is totally removed.
It would be even riskier to rename a reference to an identifier and not rename the identifier itself. :)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Search with "Whole words only" option should omit @

Post by Little John »

TI-994A wrote:Operators and address references never form any part of an identifier.
Yes, that's true. I can't see where I wrote anything different. :-)
What obviously adds to the confusion here is, that the asterisk * can play both the role of an operator, and the role of a part of an identifier (pointer variable).
TI-994A wrote:[...] best practices recommend leaving spaces between variables and operators. :)
Yep!
That's exactly what I'm doing when writing new PB code.
However, there are not always spaces between variables and operators in my old code, let alone code which I copied e.g. from this forum.
And this will not solve the problem with @ ...
Last edited by Little John on Wed May 21, 2014 6:23 pm, edited 1 time in total.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Search with "Whole words only" option should omit @

Post by Tenaja »

Little John wrote: In other words, when I want to reliably search and replace a variable or procedure name, I'll have to do 3 search and replace operations:
- one with identifier
- one with @identifier
- one with *identifier

Not exactly a satisfying solution.
This is one of the major reasons I always place spaces around every operator. Even the @ operator allows a space, as wrong as it looks.
Post Reply