简体   繁体   English

在Smalltalk IDE(Squeak,VisualWorks等)上,您如何远离正在处理的消息代码来检查另一个?

[英]On Smalltalk IDEs (Squeak, VisualWorks, etc), how can you navigate away from a message's code you're working on to inspect another?

In every IDE I've tried so far, if I'm partway through writing a message and need to look at the code of another, the browser asks me if I want to save. 在我迄今为止尝试的每个IDE中,如果我在编写消息的过程中需要查看另一个消息的代码,浏览器会询问我是否要保存。 But if I say I do want to save, it actually tries to compile/syntax check the code, and refuses to perform the save if it does not pass. 但是,如果我说我确实想要保存,它实际上会尝试编译/语法检查代码,并拒绝执行保存,如果它没有通过。 The only way to view the source of another message seems to be to say "no" to save and have everything wiped. 查看另一条消息来源的唯一方法似乎是说“不”要保存并将所有内容擦除。 How can I look at another class incidentally, or save code I am partway through working on that might not build right now? 我怎样才能顺便看一下另一个课程,或者保存代码我正在进行的工作可能不会立即构建?

Smalltalk is a multi-browser system. Smalltalk是一个多浏览器系统。 You'll need to have lots of different browsers open. 您需要打开许多不同的浏览器。 Smalltalk is opinionated. Smalltalk是固执己见的。 The system browser (Nautilus) doesn't make it easy to view long methods, steering you towards writing short ones. 系统浏览器(Nautilus)不容易查看长方法,引导您编写简短方法。 It doesn't make it easy to have non-compiling code in a method, to steer you towards making small changes. 在方法中使用非编译代码并不容易,引导您进行小的更改。

Experimental/prototypical code you might want to have in a Workspace/Playground. 您可能希望在Workspace / Playground中拥有的实验/原型代码。 That can save to disk. 这可以保存到磁盘。

We are aware that it is an issue for people new to Smalltalk. 我们意识到对Smalltalk新手来说这是一个问题。 We tried some fixes, they were a lot worse. 我们尝试了一些修复,但情况要糟糕得多。

For now there is no easy way to do that. 目前还没有简单的方法可以做到这一点。 The two easiest opting are 两个最简单的选择是

  1. Make the current method syntactically correct and save it. 使当前方法在语法上正确并保存它。
  2. Open another browser. 打开另一个浏览器 If you want to see a class or method that is in your current code, you can cmd+click it or use "browse it", "implementors of", shortcuts that will open another window. 如果要查看当前代码中的类或方法,可以cmd +单击它或使用“浏览它”,“实现者”,将打开另一个窗口的快捷方式。

Also in you can use GTSpotter to quickly find what you are looking for and preview its source code 同样在您可以使用GTSpotter快速找到您要查找的内容并预览其源代码

When you say "this seems like a pretty huge thing to be missing, and it could be gotten around by just having the option to use a regular editor" I'm afraid you've entirely missed the point. 当你说“这似乎是一个非常巨大的东西要丢失,它可以通过选择使用常规编辑器来解决”我担心你完全错过了这一点。

Understandable, though -- happens to us all. 但是,可以理解 - 发生在我们所有人身上。 Or did. 或者做到了。 Perhaps it was long ago, but we were all there. 也许很久以前,但我们都在那里。

You might be thinking about the task in terms of scrolling a giant text up and down to find what you want. 您可能正在考虑上下滚动巨型文本以找到所需内容的任务。 Scroll up -- read a little -- scroll back -- and continue making your changes. 向上滚动 - 阅读一点 - 向后滚动 - 继续进行更改。

And when you say " I can't imagine any circumstance where it is OK, in pursuit of any agenda, to throw away the coder's work against their will " 当你说“我无法想象任何情况下它可以,在追求任何议程时,抛弃编码人员的工作违背他们的意愿”

you are spot on correct, of course. 当然,你是正确的。

Imagine -- scrolling around, making dozens of little changes, and before you've saved them -- poof -- they're all thrown away -- a mistake, perhaps, but completely against your will. 想象一下 - 滚动,做几十个小小的变化,然后在你拯救它们之前 - 噗 - 它们都被扔掉 - 这可能是一个错误,但完全违背你的意愿。 That would be awful . 太糟糕了 We're agreed. 我们同意了。

(In fact, the editor I'm using to type this (事实上​​,我正在使用的编辑器输入此内容
is like that -- I can scroll around the whole thing, 就像那样 - 我可以滚动整个事情,
making little improvements, all over, but it could 整个过程都做了一些改进,但它可以
all go --poof-- and disappear, All of it. 所有人都去了 - 并且消失了。
Fairly common occurrence, when editing the web. 在编辑网页时非常常见。 )

So let's try another run through that same task. 所以让我们尝试另一个完成同样的任务。

You get one little teensy, DUMB AS A POST editor, 你得到一个小小的,DUMB作为一个POST编辑器,
where you can only see one thing at a time. 你一次只能看到一件事。
And now you just want to scroll somewhere else, 而现在你只想滚动到其他地方,
for a moment, and come right back. 片刻,然后回来。

Which actually means that 这实际上意味着什么

you are attempting to look up a second method, 你试图查找第二种方法,
while already changing a first method 虽然已经改变了第一种方法
(which would require the browser to (这需要浏览器
forget the context of the first method, 忘记第一种方法的背景,
and move to the second). 然后转到第二个)。

The browser does not know how long you will be away from this context. 浏览器不知道你将离开这个环境多久。
You might go chaining along from place to place, stop and read an email, 您可能会从一个地方到另一个地方进行链接,停下来阅读电子邮件,
take a call, and go to lunch. 接电话,去吃午饭。

So, the browser cautions 所以,浏览器警告

"Hey - want to save this first?"

as if to say: 好像在说:

"
  Hey - I can't imagine any circumstance where it is OK,
  in pursuit of any agenda, to throw away the coder's work
  against their will.

  So listen up, coder.

  You want to save this first?
"

But you can't save it. 但你无法保存它。
You must first look something up. 你必须先看一下。
Conundrum. 难题。

Ah-ha! 啊,哈! There is a list of methods in that other pane. 其他窗格中有一个方法列表。
One of them is highlighted. 其中一个突出显示。

Not those -- that one. 不是那些 - 那一个。
Double click that one. 双击那一个。
The one you're already in. 那个你已经在的人。

As if to say 好像要说

" Thanks.  Good catch.
  Yes, I know - can't though.
  I need to change contexts.
  You stay right here.
  And give me another context
  to go wandering about in.
  please.
"

Soon, I expect, they'll start actually talking. 很快,我预计,他们会开始真正说话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM