Re: Stupidish question - scoping a class to the console
Re: Stupidish question - scoping a class to the console
- Subject: Re: Stupidish question - scoping a class to the console
- From: Jim Ingham <email@hidden>
- Date: Thu, 01 Sep 2016 11:56:55 -0700
Okay, that's clear now. Your suggestion would require the expression parser to accept code that is not legal ObjC, so it is not something we are likely to do that way, for the reasons given previously.
OTOH, you could pretty easily make a regex command that would do this substitution for you, something like:
command regex console-po "s/(.*)/expr -O -- [Console %1]/"
Then you could type:
(lldb) console-po myMethodToDebugStuff:myString
and it would translate to
(lldb) expr -O -- [Console myMethodToDebugStuff:myString]
"po is a alias for "expr -O --". See "help command regex" for more details. Also, if you end up playing around with writing regular expression commands, doing:
(lldb) settings set interpreter.expand-regex-aliases true
is very handy.
Jim
> On Sep 1, 2016, at 11:39 AM, Alex Zavatone <email@hidden> wrote:
>
> I thought I did. Apparently I must have done so poorly. Let's try again.
>
> When I'm at a breakpoint, some variables are in scope.
>
> Maybe I'd like to perform an operation on them.
>
> Maybe I'd like to just dump the contents of my database.
>
> But, If we have any classes with public methods, we have to type the name of the class and then the method (after the po, of course).
>
> If we could declare a class as Console.m and every public class method within Console.m was assumed to be what you wanted to invoke if you typed this in the console:
>
> po [myMethodToDebugStuff:myString]
>
> Once entered, the console would say, "oh, gee, look, there's no class name for the method! We'll use the Console' class then and substitute it in!" That would expand into:
>
> po [Console mymethodToDebugStuff:myString]
>
> But you would only have to type
>
> po [myMethodToDebugStuff:myString]
>
> It's like this, "if you neglect to enter a class name when typing po [MyClass myMethod], then just substitute in whatever class name we have scoped to be the "Class to use when a class name is ommtted in the console."
>
> And within Console.m, we would have all the public methods that we need or want or decide to put there.
>
> Just likeā¦
>
> + (NSString *) mymethodToDebugStuff:(NString *)myString;
>
>
> "Every method in this class will be able to be be called from the console without having to enter its class, because we have scoped it to the console for this purpose."
>
>
> I'm just trying to come up with ways to say, "I use these methods EXCLUSIVELY in console debugging. Why do I have to enter the class name in this case?"
>
>
> Does that make more sense? I'm stupid tired at the moment and words that make sense are hard. .xcscmblueprint tree merge conflicts on identical files need to die in a fire.
>
> Thanks Jim. 'Tis appreciated
>
> - Alex "Sleepy" Zavatone
>
>
>
>
> On Sep 1, 2016, at 12:27 PM, Jim Ingham wrote:
>
>> I'm not sure what you are asking for. Can you give an example of what you would like to be able to type?
>>
>> One caveat, the arguments to po have to form a legit ObjC++ expressions. We try very hard not to add "debugger language" features to the expression parser. As much as possible we want you to be able to cut & paste code from the the source window in current context and use it in the expression parser ('po' is just a fancy use of the expression parser.) We're not always perfect at this but where we aren't those are always bugs, not features. Anytime we make the "expr" language diverge from the source language of the current frame, we make this harder to achieve. So if you want to type something that isn't legal ObjC syntax, we're probably going to be resistant to the idea.
>>
>> Jim
>>
>>
>>
>>> On Aug 31, 2016, at 7:02 PM, Alex Zavatone <email@hidden> wrote:
>>>
>>> Just wondering if this is remotely possible.
>>>
>>> If I have a utility class that has public methods, I often end up typing po [MyUtilityClassThatDoesThingsThatAreUseFulToMe validateURLICareAbout:theURLThatWasJustSetInCodeAndIsLocalToTheCurrentMethod] in the console window.
>>>
>>> This blows.
>>>
>>> Of course, it I renamed the variable in question to myURL, that's a rational first step, but it's the fact that I have to type a class of a class that has a public method that I want to use while in the console.
>>>
>>> Now, I can name my class A, but that also blows.
>>>
>>> What would make sense would be to have an implicit or explicitly declared console scope to that this class automagically comes into scope when invoked through the console and outside of the console (or anything attempting to fake itself as the console, instantly returns when executed.
>>>
>>> Almost like a popup of a collection of classes to be declared as, "I apply to the console so you don't need to enter my class name there, the methods within me have been assumed to be in scope for the console and are assumed to apply to me."
>>>
>>> Are there any Xcode console plugins that anyone is aware of that might already do this? I can't be the first person to want to type less in the console.
>>>
>>> Does that make any sense?
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden