FileIn in Amber Smalltalk?

45 views
Skip to first unread message

RichardR

unread,
Aug 2, 2021, 10:42:04 AM8/2/21
to amber-lang
Hi all, is there a wat to fileIn smalltalk source files in Amber,
to force recompilation with the newest updates?

Herby Vojčík

unread,
Aug 6, 2021, 8:35:50 AM8/6/21
to amber...@googlegroups.com, RichardR
On 2. 8. 2021 16:42, RichardR wrote:
> Hi all, is there a wat to fileIn smalltalk source files in Amber,
> to force recompilation with the newest updates?

I do not understand "to force recompilation with the newest updates".
Maybe you seek other functionality than the filein. Anyway, in legacy
IDE, there is a fileIn button in Workspace.

What are you actually trying to accomplish?

Herby

> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to amber-lang+...@googlegroups.com
> <mailto:amber-lang+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com
> <https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Richard Ronteltap

unread,
Aug 6, 2021, 9:36:22 AM8/6/21
to amber-lang
Ah, I missed that button!
But pressing it does not give any reaction or error message.
Tried is on my dev env and on the official site.
How is it supposed to work?

The use case is that I want to fileIn my *.st souce files, in a fresh new Amber project.
BTW: I have done it now, but per method. A bit awkward of course.

Herby Vojčík

unread,
Aug 9, 2021, 4:56:38 AM8/9/21
to amber...@googlegroups.com, Richard Ronteltap
On 6. 8. 2021 15:36, Richard Ronteltap wrote:
> Ah, I missed that button!
> But pressing it does not give any reaction or error message.
> Tried is on my dev env and on the official site.
> How is it supposed to work?
>
> The use case is that I want to fileIn my *.st souce files, in a fresh
> new Amber project.

You are telling me _how_ you want to do it, I asked _what_ you want to
accomplish.

From what you tell me, you want to reuse some existing Amber sources
from existing project in a new project. That is not done via file in.
There's easier way. Is that your case? If yes, read on. If not, I
actually don't know why fileIn button does not work; from what I see in
code, it actually imports .st format (of the Amber flavor; so maybe a
preamble need hand-update if you copied non-Amber Smalltalk code).
Instruction for reuse of existing Amber code follows.

Do not get intimidated that the instructions seems long; they are
(IMNSHO) simple, I just wanted to outline it so there isn't any error
during the process (feel free to backup before doing anything).

You can _actually_ reuse the files from existing project (if they have
.js as well). Firstly, you can make it into library (but that's another
story) and simply add it as npm dependency. In the case you just want to
to copy sources over, just copy the src old old project into, say, src2
in new project. Then, add new namespace (eg. "old") pointing to "src2"
into local.amd.json. Then, run `grunt devel`, which should detect the
change and include new namespace into config.js. Then, load your project
and and add 'old/NameOfOldPackage' (and other packages if there were
more packages) into your imports: section in your main app package. Then
commit and reload; and the the old package(s) is loaded.

It's up to you if keep it in src2 with namespace "old" (awkward), or
move it over to yout main src, which you can do two ways: either change
namespace of old packages to the one of your new app, thereby including
new packages into you main namespace; or change the namespace to
completely new one (you can have more namespaces in your project). In
both cases, commit (Amber can ask you for a path, suggesting src IIRC,
if you chose new namespace). Then (!IMPORANT!) fix your import: section
to point at packages saved in new namespaces. Commit. In case you chose
the new namespace, add it to local.amd.json and run `grunt devel`.
Reload. Packages should be loaded from new position in your src/. You
can remove src2/ as well as namespace pointing at src2/ from you
local.amd.json. Run `grunt devel` to regenerate config.js. Reload.

Herby

P.S.: Whenever you add an .st/.js pair into your project (that is, you
add a package), you should also update Gruntfile.js so it contains it
and recompiles it when `grunt` is run; this is used in `npm run init`
functionality; should you need to recompile completely; for example
after breaking Amber update. Keep Gruntfile.js in sync with your src/.

P.P.S.: If it's piece of reusable code, I would suggest to make it a
library instead. An app itself _is_ a reusable library, technically, but
actual library would need a bit of a cleanup (and, ideally, publishing
in npm). Then, reusing the code is as easy as "npm install the_lib
--save", running `grunt devel` which finds it in node_modules and uses
its local.amd.json to generate a paths line in condig.js, reload, and
then adding the import: section with 'lib_namespace/LibPackage'. That
presumes the library has unique enough namespace so it won't collision
with your app or another lib in the future.

P.P.P.S.: There's still `amberc` which compiles (amber-variant) of .st
file directly from cli; if you just want to move one file into your
project, that may be the easiest way (but again, add import: section to
your main package so it is actually loaded).

> BTW: I have done it now, but per method. A bit awkward of course.
>
> On Friday, 6 August 2021 at 14:35:50 UTC+2 Herby wrote:
>
> On 2. 8. 2021 16:42, RichardR wrote:
> > Hi all, is there a wat to fileIn smalltalk source files in Amber,
> > to force recompilation with the newest updates?
>
> I do not understand "to force recompilation with the newest updates".
> Maybe you seek other functionality than the filein. Anyway, in legacy
> IDE, there is a fileIn button in Workspace.
>
> What are you actually trying to accomplish?
>
> Herby
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "amber-lang" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to amber-lang+...@googlegroups.com
> > <mailto:amber-lang+...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com
> <https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com>
>
> >
> <https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/amber-lang/801fad2c-984b-4780-ad59-81bbf3d3647fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to amber-lang+...@googlegroups.com
> <mailto:amber-lang+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/amber-lang/bbb70d53-9865-46be-854c-3c535be1f3b9n%40googlegroups.com
> <https://groups.google.com/d/msgid/amber-lang/bbb70d53-9865-46be-854c-3c535be1f3b9n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Richard Ronteltap

unread,
Aug 9, 2021, 3:44:02 PM8/9/21
to amber-lang
Thanks for the extensive response.
The easiest way was indeed to paste all the module code into a workspace and then press fileIn.
I was a bit confused because I assumed it was going to let me select an actual file,
and sample input I typed in the workspace did not produce an error.

Reply all
Reply to author
Forward
0 new messages