[ANN] Amber now includes a REPL (cool!)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Amber now includes a REPL (cool!)

Nicolas Petton
Hi guys,

I just pushed a simple REPL written top of node.js.
You can run it with:

./bin/amber

The REPL is written in Amber, you can browse the code at repl/REPL.st

Cheers,
Nico

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
Good,

Amber will become a "regular" scripting language in addition to
"living" on the browser and having a command line compiler from amber
to Javascript!!

I did a amber.bat file (modeled) after server.bat for MSWindows

amber.bat contains

@cd "%~dp0\.."
@node ./repl/repl.js

then if I start I get
amber>>

What do I do next?

help

gives
nil

how do I get out again

exit
quit
end
do not work (adding a dot does not help).
and adding a self in  front of it neither.

A little bit of documentation is needed ......

--Hannes

On 10/22/11, Nicolas Petton <[hidden email]> wrote:

> Hi guys,
>
> I just pushed a simple REPL written top of node.js.
> You can run it with:
>
> ./bin/amber
>
> The REPL is written in Amber, you can browse the code at repl/REPL.st
>
> Cheers,
> Nico
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Nicolas Petton
Evaluate regular Smalltalk code, line by line.

amber >> 1+1
2
amber >> Object new
a Object
amber >>

To exit, ctrl+c (or ctrl+d)


Cheers,
Nico

On Sat, 2011-10-22 at 14:12 +0000, H. Hirzel wrote:

> Good,
>
> Amber will become a "regular" scripting language in addition to
> "living" on the browser and having a command line compiler from amber
> to Javascript!!
>
> I did a amber.bat file (modeled) after server.bat for MSWindows
>
> amber.bat contains
>
> @cd "%~dp0\.."
> @node ./repl/repl.js
>
> then if I start I get
> amber>>
>
> What do I do next?
>
> help
>
> gives
> nil
>
> how do I get out again
>
> exit
> quit
> end
> do not work (adding a dot does not help).
> and adding a self in  front of it neither.
>
> A little bit of documentation is needed ......
>
> --Hannes
>
> On 10/22/11, Nicolas Petton <[hidden email]> wrote:
> > Hi guys,
> >
> > I just pushed a simple REPL written top of node.js.
> > You can run it with:
> >
> > ./bin/amber
> >
> > The REPL is written in Amber, you can browse the code at repl/REPL.st
> >
> > Cheers,
> > Nico
> >
> >


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
That works fine, thank you.

--Hannes

S:\chrono2011work\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
amber >> a := 1+1.
2
amber >> a
2


There seem to be no global variables in Amber, right?

amber >> A := 1 + 1.
a Repl>>eval:
a Compiler>>loadExpression:
a Compiler>>compileExpression:
a Compiler>>parse:
a Smalltalk>>parse:
a Smalltalk>>try:catch:
a Smalltalk>>basicParse:
Parse error on line 1 column 10 : Expected ".", ";", "]", [
♂♀\xA0\uFEFF\n\r\u2028\u2029], ["], [.], [\\+*\/=><,@%~|&\-] or [a-z]
but ":" found. Below is code with line numbers and ===> marker
inserted:
1: doIt ^[A  ===>:= 1 + 1.] value


On 10/22/11, Nicolas Petton <[hidden email]> wrote:

> Evaluate regular Smalltalk code, line by line.
>
> amber >> 1+1
> 2
> amber >> Object new
> a Object
> amber >>
>
> To exit, ctrl+c (or ctrl+d)
>
>
> Cheers,
> Nico
>
> On Sat, 2011-10-22 at 14:12 +0000, H. Hirzel wrote:
>> Good,
>>
>> Amber will become a "regular" scripting language in addition to
>> "living" on the browser and having a command line compiler from amber
>> to Javascript!!
>>
>> I did a amber.bat file (modeled) after server.bat for MSWindows
>>
>> amber.bat contains
>>
>> @cd "%~dp0\.."
>> @node ./repl/repl.js
>>
>> then if I start I get
>> amber>>
>>
>> What do I do next?
>>
>> help
>>
>> gives
>> nil
>>
>> how do I get out again
>>
>> exit
>> quit
>> end
>> do not work (adding a dot does not help).
>> and adding a self in  front of it neither.
>>
>> A little bit of documentation is needed ......
>>
>> --Hannes
>>
>> On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> > Hi guys,
>> >
>> > I just pushed a simple REPL written top of node.js.
>> > You can run it with:
>> >
>> > ./bin/amber
>> >
>> > The REPL is written in Amber, you can browse the code at repl/REPL.st
>> >
>> > Cheers,
>> > Nico
>> >
>> >
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
The code is actually pretty short!

https://github.com/NicolasPetton/amber/blob/master/repl/REPL.st

Another question:

What is the 'require' object in the the 'initialize' method?

-- HH



Object subclass: #Repl
instanceVariableNames: 'readline interface util'
category: 'REPL'!

!Repl methodsFor: 'accessing'!

prompt
^'amber >> '
! !

!Repl methodsFor: 'actions'!

createInterface
"No completion for now"
interface := readline createInterface: process stdin stdout: process stdout.
interface on: 'line' do: [:buffer | self eval: buffer].
interface on: 'close' do: [self close].
self setPrompt.
interface prompt
!

setPrompt
interface setPrompt: self prompt
!

close
process stdin destroy
!

eval: buffer
| result |
buffer isEmpty ifFalse: [
result := Compiler new loadExpression: buffer.
Transcript show: result].
self setPrompt.
interface prompt
! !

!Repl methodsFor: 'initialization'!

initialize
super initialize.
readline := require value: 'readline'.
util := require value: 'util'
! !

!Repl class methodsFor: 'not yet classified'!

main
self new createInterface
! !




On 10/22/11, H. Hirzel <[hidden email]> wrote:

> That works fine, thank you.
>
> --Hannes
>
> S:\chrono2011work\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
> amber >> a := 1+1.
> 2
> amber >> a
> 2
>
>
> There seem to be no global variables in Amber, right?
>
> amber >> A := 1 + 1.
> a Repl>>eval:
> a Compiler>>loadExpression:
> a Compiler>>compileExpression:
> a Compiler>>parse:
> a Smalltalk>>parse:
> a Smalltalk>>try:catch:
> a Smalltalk>>basicParse:
> Parse error on line 1 column 10 : Expected ".", ";", "]", [
> ♂♀\xA0\uFEFF\n\r\u2028\u2029], ["], [.], [\\+*\/=><,@%~|&\-] or [a-z]
> but ":" found. Below is code with line numbers and ===> marker
> inserted:
> 1: doIt ^[A  ===>:= 1 + 1.] value
>
>
> On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> Evaluate regular Smalltalk code, line by line.
>>
>> amber >> 1+1
>> 2
>> amber >> Object new
>> a Object
>> amber >>
>>
>> To exit, ctrl+c (or ctrl+d)
>>
>>
>> Cheers,
>> Nico
>>
>> On Sat, 2011-10-22 at 14:12 +0000, H. Hirzel wrote:
>>> Good,
>>>
>>> Amber will become a "regular" scripting language in addition to
>>> "living" on the browser and having a command line compiler from amber
>>> to Javascript!!
>>>
>>> I did a amber.bat file (modeled) after server.bat for MSWindows
>>>
>>> amber.bat contains
>>>
>>> @cd "%~dp0\.."
>>> @node ./repl/repl.js
>>>
>>> then if I start I get
>>> amber>>
>>>
>>> What do I do next?
>>>
>>> help
>>>
>>> gives
>>> nil
>>>
>>> how do I get out again
>>>
>>> exit
>>> quit
>>> end
>>> do not work (adding a dot does not help).
>>> and adding a self in  front of it neither.
>>>
>>> A little bit of documentation is needed ......
>>>
>>> --Hannes
>>>
>>> On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>>> > Hi guys,
>>> >
>>> > I just pushed a simple REPL written top of node.js.
>>> > You can run it with:
>>> >
>>> > ./bin/amber
>>> >
>>> > The REPL is written in Amber, you can browse the code at repl/REPL.st
>>> >
>>> > Cheers,
>>> > Nico
>>> >
>>> >
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

gokr
In reply to this post by Hannes Hirzel
I wrote several nodejs examples all the way back at ESUG in fact. amberc in itself runs on node. So if you look at the examples directory you find several node examples. The REPL does not really give you anything new - except for playing/experimenting of course. But the workspace is better IMHO.

regards' Göran


-- Sent from my HP TouchPad

On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
Good,

Amber will become a "regular" scripting language in addition to
"living" on the browser and having a command line compiler from amber
to Javascript!!

I did a amber.bat file (modeled) after server.bat for MSWindows

amber.bat contains

@cd "%~dp0\.."
@node ./repl/repl.js

then if I start I get
amber>>

What do I do next?

help

gives
nil

how do I get out again

exit
quit
end
do not work (adding a dot does not help).
and adding a self in front of it neither.

A little bit of documentation is needed ......

--Hannes

On 10/22/11, Nicolas Petton <[hidden email]> wrote:

> Hi guys,
>
> I just pushed a simple REPL written top of node.js.
> You can run it with:
>
> ./bin/amber
>
> The REPL is written in Amber, you can browse the code at repl/REPL.st
>
> Cheers,
> Nico
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
Thank you Göran

I found the examples. They are under examples\nodejs.

In particular I like TrivialServer.st.

I did not see an example for reading a text file and processing it.
When I browse through the classes I do not see a class for doing file
I/O. I think file I/O is something needed to have a complete REPL
experience.

nodejs has a File class

http://nodejs.org/docs/v0.0.1/api.html#file_file

with an example of

var file = new node.fs.File();
file.open("/tmp/blah", "w+");
file.write("hello");
file.write("world");
file.close();

How would this be written in Amber?

Thank you for the answer in advance
--Hannes

On 10/22/11, [hidden email] <[hidden email]> wrote:

> I wrote several nodejs examples all the way back at ESUG in fact. amberc in
> itself runs on node. So if you look at the examples directory you find
> several node examples. The REPL does not really give you anything new -
> except for playing/experimenting of course. But the workspace is better
> IMHO.
>
> regards' Göran
>
>
> -- Sent from my HP TouchPad
> ________________________________
> On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
> Good,
>
> Amber will become a "regular" scripting language in addition to
> "living" on the browser and having a command line compiler from amber
> to Javascript!!
>
> I did a amber.bat file (modeled) after server.bat for MSWindows
>
> amber.bat contains
>
> @cd "%~dp0\.."
> @node ./repl/repl.js
>
> then if I start I get
> amber>>
>
> What do I do next?
>
> help
>
> gives
> nil
>
> how do I get out again
>
> exit
> quit
> end
> do not work (adding a dot does not help).
> and adding a self in front of it neither.
>
> A little bit of documentation is needed ......
>
> --Hannes
>
> On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> Hi guys,
>>
>> I just pushed a simple REPL written top of node.js.
>> You can run it with:
>>
>> ./bin/amber
>>
>> The REPL is written in Amber, you can browse the code at repl/REPL.st
>>
>> Cheers,
>> Nico
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

laurent laffont
In reply to this post by Nicolas Petton
Thanks a lot Nicolas !

Laurent.

On Sat, Oct 22, 2011 at 3:20 PM, Nicolas Petton <[hidden email]> wrote:
Hi guys,

I just pushed a simple REPL written top of node.js.
You can run it with:

./bin/amber

The REPL is written in Amber, you can browse the code at repl/REPL.st

Cheers,
Nico


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Nicolas Petton
In reply to this post by Hannes Hirzel
On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:

> nodejs has a File class
>
> http://nodejs.org/docs/v0.0.1/api.html#file_file
>
> with an example of
>
> var file = new node.fs.File();
> file.open("/tmp/blah", "w+");
> file.write("hello");
> file.write("world");
> file.close();
>
> How would this be written in Amber?

The API has evolved since 0.0.1 :)
http://nodejs.org/docs/v0.4.12/api/fs.html

There's an example in the server/ directory. FileServer.st handles GET
requests (answers the contents of files) and PUT requests (write to
files).

https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66

Cheers,
Nico

>
> Thank you for the answer in advance
> --Hannes
>
> On 10/22/11, [hidden email] <[hidden email]> wrote:
> > I wrote several nodejs examples all the way back at ESUG in fact. amberc in
> > itself runs on node. So if you look at the examples directory you find
> > several node examples. The REPL does not really give you anything new -
> > except for playing/experimenting of course. But the workspace is better
> > IMHO.
> >
> > regards' Göran
> >
> >
> > -- Sent from my HP TouchPad
> > ________________________________
> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
> > Good,
> >
> > Amber will become a "regular" scripting language in addition to
> > "living" on the browser and having a command line compiler from amber
> > to Javascript!!
> >
> > I did a amber.bat file (modeled) after server.bat for MSWindows
> >
> > amber.bat contains
> >
> > @cd "%~dp0\.."
> > @node ./repl/repl.js
> >
> > then if I start I get
> > amber>>
> >
> > What do I do next?
> >
> > help
> >
> > gives
> > nil
> >
> > how do I get out again
> >
> > exit
> > quit
> > end
> > do not work (adding a dot does not help).
> > and adding a self in front of it neither.
> >
> > A little bit of documentation is needed ......
> >
> > --Hannes
> >
> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
> >> Hi guys,
> >>
> >> I just pushed a simple REPL written top of node.js.
> >> You can run it with:
> >>
> >> ./bin/amber
> >>
> >> The REPL is written in Amber, you can browse the code at repl/REPL.st
> >>
> >> Cheers,
> >> Nico
> >>
> >>


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
Nico,

thank you for the link to nodejs  0.4.12  :-)

The FileServer.st program is an example, right? It is not used by the
"regular" server?

Learning from FileServer.st (initialize method)

I did

fs := self require: 'fs'.

It was not successful.

Tjhen I did

obj := Object new.
obj require: 'fs'.

Both times it said that it does not understand #require:

Then I went for
<var fs  = require('fs');>

Am I missing something here or are there parts which are not yet implemented?

I want to read and write a text file in the REPL.

--Hannes


On 10/23/11, Nicolas Petton <[hidden email]> wrote:

> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> nodejs has a File class
>>
>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>>
>> with an example of
>>
>> var file = new node.fs.File();
>> file.open("/tmp/blah", "w+");
>> file.write("hello");
>> file.write("world");
>> file.close();
>>
>> How would this be written in Amber?
>
> The API has evolved since 0.0.1 :)
> http://nodejs.org/docs/v0.4.12/api/fs.html
>
> There's an example in the server/ directory. FileServer.st handles GET
> requests (answers the contents of files) and PUT requests (write to
> files).
>
> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>
> Cheers,
> Nico
>
>>
>> Thank you for the answer in advance
>> --Hannes
>>
>> On 10/22/11, [hidden email] <[hidden email]> wrote:
>> > I wrote several nodejs examples all the way back at ESUG in fact. amberc
>> > in
>> > itself runs on node. So if you look at the examples directory you find
>> > several node examples. The REPL does not really give you anything new -
>> > except for playing/experimenting of course. But the workspace is better
>> > IMHO.
>> >
>> > regards' Göran
>> >
>> >
>> > -- Sent from my HP TouchPad
>> > ________________________________
>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
>> > Good,
>> >
>> > Amber will become a "regular" scripting language in addition to
>> > "living" on the browser and having a command line compiler from amber
>> > to Javascript!!
>> >
>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >
>> > amber.bat contains
>> >
>> > @cd "%~dp0\.."
>> > @node ./repl/repl.js
>> >
>> > then if I start I get
>> > amber>>
>> >
>> > What do I do next?
>> >
>> > help
>> >
>> > gives
>> > nil
>> >
>> > how do I get out again
>> >
>> > exit
>> > quit
>> > end
>> > do not work (adding a dot does not help).
>> > and adding a self in front of it neither.
>> >
>> > A little bit of documentation is needed ......
>> >
>> > --Hannes
>> >
>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >> Hi guys,
>> >>
>> >> I just pushed a simple REPL written top of node.js.
>> >> You can run it with:
>> >>
>> >> ./bin/amber
>> >>
>> >> The REPL is written in Amber, you can browse the code at repl/REPL.st
>> >>
>> >> Cheers,
>> >> Nico
>> >>
>> >>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

gokr
In reply to this post by Nicolas Petton
require is a function. Call it as if it was a block:

fs = require value: 'os'

Funky, right? :)

-- Sent from my Palm Pre 2, wohoo!


On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:

Nico,

thank you for the link to nodejs 0.4.12 :-)

The FileServer.st program is an example, right? It is not used by the
"regular" server?

Learning from FileServer.st (initialize method)

I did

fs := self require: 'fs'.

It was not successful.

Tjhen I did

obj := Object new.
obj require: 'fs'.

Both times it said that it does not understand #require:

Then I went for
<var fs = require('fs');>

Am I missing something here or are there parts which are not yet implemented?

I want to read and write a text file in the REPL.

--Hannes


On 10/23/11, Nicolas Petton <[hidden email]> wrote:

> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> nodejs has a File class
>>
>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>>
>> with an example of
>>
>> var file = new node.fs.File();
>> file.open("/tmp/blah", "w+");
>> file.write("hello");
>> file.write("world");
>> file.close();
>>
>> How would this be written in Amber?
>
> The API has evolved since 0.0.1 :)
> http://nodejs.org/docs/v0.4.12/api/fs.html
>
> There's an example in the server/ directory. FileServer.st handles GET
> requests (answers the contents of files) and PUT requests (write to
> files).
>
> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>
> Cheers,
> Nico
>
>>
>> Thank you for the answer in advance
>> --Hannes
>>
>> On 10/22/11, [hidden email] <[hidden email]> wrote:
>> > I wrote several nodejs examples all the way back at ESUG in fact. amberc
>> > in
>> > itself runs on node. So if you look at the examples directory you find
>> > several node examples. The REPL does not really give you anything new -
>> > except for playing/experimenting of course. But the workspace is better
>> > IMHO.
>> >
>> > regards' Göran
>> >
>> >
>> > -- Sent from my HP TouchPad
>> > ________________________________
>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
>> > Good,
>> >
>> > Amber will become a "regular" scripting language in addition to
>> > "living" on the browser and having a command line compiler from amber
>> > to Javascript!!
>> >
>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >
>> > amber.bat contains
>> >
>> > @cd "%~dp0\.."
>> > @node ./repl/repl.js
>> >
>> > then if I start I get
>> > amber>>
>> >
>> > What do I do next?
>> >
>> > help
>> >
>> > gives
>> > nil
>> >
>> > how do I get out again
>> >
>> > exit
>> > quit
>> > end
>> > do not work (adding a dot does not help).
>> > and adding a self in front of it neither.
>> >
>> > A little bit of documentation is needed ......
>> >
>> > --Hannes
>> >
>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >> Hi guys,
>> >>
>> >> I just pushed a simple REPL written top of node.js.
>> >> You can run it with:
>> >>
>> >> ./bin/amber
>> >>
>> >> The REPL is written in Amber, you can browse the code at repl/REPL.st
>> >>
>> >> Cheers,
>> >> Nico
>> >>
>> >>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
This brings a different error message.

S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
amber >> fs := require value: 'fs'.

S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
                                        throw(error);
           ^
TypeError: Object #<Object> has no method '_asString'
    at [object Object]._show_
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
    at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
    at Smalltalk.send
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
 <snip>




S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
amber >> fs := require value: 'os'.

S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
                                        throw(error);
           ^
TypeError: Object #<Object> has no method '_asString'
    at [object Object]._show_
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
    at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
    at Smalltalk.send
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
<snip>



S:\Project\amber\NicolasPetton-amber-0.9-124>


Other ideas?

--HJH

On 10/24/11, Göran Krampe <[hidden email]> wrote:

> require is a function. Call it as if it was a block:
>
> fs = require value: 'os'
>
> Funky, right? :)
>
> -- Sent from my Palm Pre 2, wohoo!
>
> ________________________________
> On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>
> Nico,
>
> thank you for the link to nodejs 0.4.12 :-)
>
> The FileServer.st program is an example, right? It is not used by the
> "regular" server?
>
> Learning from FileServer.st (initialize method)
>
> I did
>
> fs := self require: 'fs'.
>
> It was not successful.
>
> Tjhen I did
>
> obj := Object new.
> obj require: 'fs'.
>
> Both times it said that it does not understand #require:
>
> Then I went for
> <var fs = require('fs');>
>
> Am I missing something here or are there parts which are not yet
> implemented?
>
> I want to read and write a text file in the REPL.
>
> --Hannes
>
>
> On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>>> nodejs has a File class
>>>
>>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>>>
>>> with an example of
>>>
>>> var file = new node.fs.File();
>>> file.open("/tmp/blah", "w+");
>>> file.write("hello");
>>> file.write("world");
>>> file.close();
>>>
>>> How would this be written in Amber?
>>
>> The API has evolved since 0.0.1 :)
>> http://nodejs.org/docs/v0.4.12/api/fs.html
>>
>> There's an example in the server/ directory. FileServer.st handles GET
>> requests (answers the contents of files) and PUT requests (write to
>> files).
>>
>> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>>
>>
>> Cheers,
>> Nico
>>
>>>
>>> Thank you for the answer in advance
>>> --Hannes
>>>
>>> On 10/22/11, [hidden email] <[hidden email]> wrote:
>>> > I wrote several nodejs examples all the way back at ESUG in fact.
>>> > amberc
>>> > in
>>> > itself runs on node. So if you look at the examples directory you find
>>> > several node examples. The REPL does not really give you anything new -
>>> >
>>> > except for playing/experimenting of course. But the workspace is better
>>> >
>>> > IMHO.
>>> >
>>> > regards' Göran
>>> >
>>> >
>>> > -- Sent from my HP TouchPad
>>> > ________________________________
>>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
>>> > Good,
>>> >
>>> > Amber will become a "regular" scripting language in addition to
>>> > "living" on the browser and having a command line compiler from amber
>>> > to Javascript!!
>>> >
>>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>>> >
>>> > amber.bat contains
>>> >
>>> > @cd "%~dp0\.."
>>> > @node ./repl/repl.js
>>> >
>>> > then if I start I get
>>> > amber>>
>>> >
>>> > What do I do next?
>>> >
>>> > help
>>> >
>>> > gives
>>> > nil
>>> >
>>> > how do I get out again
>>> >
>>> > exit
>>> > quit
>>> > end
>>> > do not work (adding a dot does not help).
>>> > and adding a self in front of it neither.
>>> >
>>> > A little bit of documentation is needed ......
>>> >
>>> > --Hannes
>>> >
>>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>>> >> Hi guys,
>>> >>
>>> >> I just pushed a simple REPL written top of node.js.
>>> >> You can run it with:
>>> >>
>>> >> ./bin/amber
>>> >>
>>> >> The REPL is written in Amber, you can browse the code at repl/REPL.st
>>> >>
>>> >> Cheers,
>>> >> Nico
>>> >>
>>> >>
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

gokr

Ah, my guess is that the repl tries to sedn asString to the result - expecting a Smalltalk object, but now it gets a node module instead. So Nicolas needs to check the result better I guess.

regards, Göran


-- Sent from my HP TouchPad

On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
This brings a different error message.

S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
amber >> fs := require value: 'fs'.

S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
throw(error);
^
TypeError: Object #<Object> has no method '_asString'
at [object Object]._show_
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
at Smalltalk.send
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
<snip>




S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
amber >> fs := require value: 'os'.

S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
throw(error);
^
TypeError: Object #<Object> has no method '_asString'
at [object Object]._show_
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
at Smalltalk.send
(S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
<snip>



S:\Project\amber\NicolasPetton-amber-0.9-124>


Other ideas?

--HJH

On 10/24/11, Göran Krampe <[hidden email]> wrote:

> require is a function. Call it as if it was a block:
>
> fs = require value: 'os'
>
> Funky, right? :)
>
> -- Sent from my Palm Pre 2, wohoo!
>
> ________________________________
> On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>
> Nico,
>
> thank you for the link to nodejs 0.4.12 :-)
>
> The FileServer.st program is an example, right? It is not used by the
> "regular" server?
>
> Learning from FileServer.st (initialize method)
>
> I did
>
> fs := self require: 'fs'.
>
> It was not successful.
>
> Tjhen I did
>
> obj := Object new.
> obj require: 'fs'.
>
> Both times it said that it does not understand #require:
>
> Then I went for
> <var fs = require('fs');>
>
> Am I missing something here or are there parts which are not yet
> implemented?
>
> I want to read and write a text file in the REPL.
>
> --Hannes
>
>
> On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>>> nodejs has a File class
>>>
>>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>>>
>>> with an example of
>>>
>>> var file = new node.fs.File();
>>> file.open("/tmp/blah", "w+");
>>> file.write("hello");
>>> file.write("world");
>>> file.close();
>>>
>>> How would this be written in Amber?
>>
>> The API has evolved since 0.0.1 :)
>> http://nodejs.org/docs/v0.4.12/api/fs.html
>>
>> There's an example in the server/ directory. FileServer.st handles GET
>> requests (answers the contents of files) and PUT requests (write to
>> files).
>>
>> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>>
>>
>> Cheers,
>> Nico
>>
>>>
>>> Thank you for the answer in advance
>>> --Hannes
>>>
>>> On 10/22/11, [hidden email] <[hidden email]> wrote:
>>> > I wrote several nodejs examples all the way back at ESUG in fact.
>>> > amberc
>>> > in
>>> > itself runs on node. So if you look at the examples directory you find
>>> > several node examples. The REPL does not really give you anything new -
>>> >
>>> > except for playing/experimenting of course. But the workspace is better
>>> >
>>> > IMHO.
>>> >
>>> > regards' Göran
>>> >
>>> >
>>> > -- Sent from my HP TouchPad
>>> > ________________________________
>>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]> wrote:
>>> > Good,
>>> >
>>> > Amber will become a "regular" scripting language in addition to
>>> > "living" on the browser and having a command line compiler from amber
>>> > to Javascript!!
>>> >
>>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>>> >
>>> > amber.bat contains
>>> >
>>> > @cd "%~dp0\.."
>>> > @node ./repl/repl.js
>>> >
>>> > then if I start I get
>>> > amber>>
>>> >
>>> > What do I do next?
>>> >
>>> > help
>>> >
>>> > gives
>>> > nil
>>> >
>>> > how do I get out again
>>> >
>>> > exit
>>> > quit
>>> > end
>>> > do not work (adding a dot does not help).
>>> > and adding a self in front of it neither.
>>> >
>>> > A little bit of documentation is needed ......
>>> >
>>> > --Hannes
>>> >
>>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>>> >> Hi guys,
>>> >>
>>> >> I just pushed a simple REPL written top of node.js.
>>> >> You can run it with:
>>> >>
>>> >> ./bin/amber
>>> >>
>>> >> The REPL is written in Amber, you can browse the code at repl/REPL.st
>>> >>
>>> >> Cheers,
>>> >> Nico
>>> >>
>>> >>
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Nicolas Petton
Yep, the bug was in ConsoleTranscript.
I pushed a fix.

Cheers,
Nico

On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:

>
> Ah, my guess is that the repl tries to sedn asString to the result -
> expecting a Smalltalk object, but now it gets a node module instead.
> So Nicolas needs to check the result better I guess.
>
> regards, Göran
>
>
> -- Sent from my HP TouchPad
>
> ______________________________________________________________________
> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
> This brings a different error message.
>
> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
> amber >> fs := require value: 'fs'.
>
> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
> throw(error);
> ^
> TypeError: Object #<Object> has no method '_asString'
> at [object Object]._show_
> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
> at Smalltalk.send
> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
> <snip>
>
>
>
>
> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
> amber >> fs := require value: 'os'.
>
> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
> throw(error);
> ^
> TypeError: Object #<Object> has no method '_asString'
> at [object Object]._show_
> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
> at Smalltalk.send
> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
> <snip>
>
>
>
> S:\Project\amber\NicolasPetton-amber-0.9-124>
>
>
> Other ideas?
>
> --HJH
>
> On 10/24/11, Göran Krampe <[hidden email]> wrote:
> > require is a function. Call it as if it was a block:
> >
> > fs = require value: 'os'
> >
> > Funky, right? :)
> >
> > -- Sent from my Palm Pre 2, wohoo!
> >
> > ________________________________
> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
> >
> > Nico,
> >
> > thank you for the link to nodejs 0.4.12 :-)
> >
> > The FileServer.st program is an example, right? It is not used by
> the
> > "regular" server?
> >
> > Learning from FileServer.st (initialize method)
> >
> > I did
> >
> > fs := self require: 'fs'.
> >
> > It was not successful.
> >
> > Tjhen I did
> >
> > obj := Object new.
> > obj require: 'fs'.
> >
> > Both times it said that it does not understand #require:
> >
> > Then I went for
> > <var fs = require('fs');>
> >
> > Am I missing something here or are there parts which are not yet
> > implemented?
> >
> > I want to read and write a text file in the REPL.
> >
> > --Hannes
> >
> >
> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
> >>> nodejs has a File class
> >>>
> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file 
> >>>
> >>> with an example of
> >>>
> >>> var file = new node.fs.File();
> >>> file.open("/tmp/blah", "w+");
> >>> file.write("hello");
> >>> file.write("world");
> >>> file.close();
> >>>
> >>> How would this be written in Amber?
> >>
> >> The API has evolved since 0.0.1 :)
> >> http://nodejs.org/docs/v0.4.12/api/fs.html 
> >>
> >> There's an example in the server/ directory. FileServer.st handles
> GET
> >> requests (answers the contents of files) and PUT requests (write
> to
> >> files).
> >>
> >>
> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66 
> >>
> >>
> >> Cheers,
> >> Nico
> >>
> >>>
> >>> Thank you for the answer in advance
> >>> --Hannes
> >>>
> >>> On 10/22/11, [hidden email] <[hidden email]>
> wrote:
> >>> > I wrote several nodejs examples all the way back at ESUG in
> fact.
> >>> > amberc
> >>> > in
> >>> > itself runs on node. So if you look at the examples directory
> you find
> >>> > several node examples. The REPL does not really give you
> anything new -
> >>> >
> >>> > except for playing/experimenting of course. But the workspace is
> better
> >>> >
> >>> > IMHO.
> >>> >
> >>> > regards' Göran
> >>> >
> >>> >
> >>> > -- Sent from my HP TouchPad
> >>> > ________________________________
> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
> wrote:
> >>> > Good,
> >>> >
> >>> > Amber will become a "regular" scripting language in addition to
> >>> > "living" on the browser and having a command line compiler from
> amber
> >>> > to Javascript!!
> >>> >
> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
> >>> >
> >>> > amber.bat contains
> >>> >
> >>> > @cd "%~dp0\.."
> >>> > @node ./repl/repl.js
> >>> >
> >>> > then if I start I get
> >>> > amber>>
> >>> >
> >>> > What do I do next?
> >>> >
> >>> > help
> >>> >
> >>> > gives
> >>> > nil
> >>> >
> >>> > how do I get out again
> >>> >
> >>> > exit
> >>> > quit
> >>> > end
> >>> > do not work (adding a dot does not help).
> >>> > and adding a self in front of it neither.
> >>> >
> >>> > A little bit of documentation is needed ......
> >>> >
> >>> > --Hannes
> >>> >
> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
> >>> >> Hi guys,
> >>> >>
> >>> >> I just pushed a simple REPL written top of node.js.
> >>> >> You can run it with:
> >>> >>
> >>> >> ./bin/amber
> >>> >>
> >>> >> The REPL is written in Amber, you can browse the code at
> repl/REPL.st
> >>> >>
> >>> >> Cheers,
> >>> >> Nico
> >>> >>
> >>> >>
> >>
> >>
> >>
> >


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
Thanks, but now a regression test shows:

REPL 0.9-129 no longer starts whereas 0.9.124 did.

--Hannes


==========================================================
S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber.bat

node.js:203
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
ReferenceError: smalltalk is not defined
    at Object.<anonymous>
(S:\Project\amber\NicolasPetton-amber-0.9-129\repl\repl.js:1:63)
    at Module._compile (module.js:416:26)
    at Object..js (module.js:434:10)
    at Module.load (module.js:335:31)
    at Function._load (module.js:294:12)
    at Array.<anonymous> (module.js:454:10)
    at EventEmitter._tickCallback (node.js:195:26)

S:\Project\amber\NicolasPetton-amber-0.9-129>cd ..

S:\Project\amber>cd NicolasPetton-amber-0.9-124

S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber.bat
amber >>

On 10/24/11, Nicolas Petton <[hidden email]> wrote:

> Yep, the bug was in ConsoleTranscript.
> I pushed a fix.
>
> Cheers,
> Nico
>
> On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:
>>
>> Ah, my guess is that the repl tries to sedn asString to the result -
>> expecting a Smalltalk object, but now it gets a node module instead.
>> So Nicolas needs to check the result better I guess.
>>
>> regards, Göran
>>
>>
>> -- Sent from my HP TouchPad
>>
>> ______________________________________________________________________
>> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
>> This brings a different error message.
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> amber >> fs := require value: 'fs'.
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> throw(error);
>> ^
>> TypeError: Object #<Object> has no method '_asString'
>> at [object Object]._show_
>> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> at Smalltalk.send
>> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> <snip>
>>
>>
>>
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> amber >> fs := require value: 'os'.
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> throw(error);
>> ^
>> TypeError: Object #<Object> has no method '_asString'
>> at [object Object]._show_
>> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> at Smalltalk.send
>> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> <snip>
>>
>>
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>
>>
>>
>> Other ideas?
>>
>> --HJH
>>
>> On 10/24/11, Göran Krampe <[hidden email]> wrote:
>> > require is a function. Call it as if it was a block:
>> >
>> > fs = require value: 'os'
>> >
>> > Funky, right? :)
>> >
>> > -- Sent from my Palm Pre 2, wohoo!
>> >
>> > ________________________________
>> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>> >
>> > Nico,
>> >
>> > thank you for the link to nodejs 0.4.12 :-)
>> >
>> > The FileServer.st program is an example, right? It is not used by
>> the
>> > "regular" server?
>> >
>> > Learning from FileServer.st (initialize method)
>> >
>> > I did
>> >
>> > fs := self require: 'fs'.
>> >
>> > It was not successful.
>> >
>> > Tjhen I did
>> >
>> > obj := Object new.
>> > obj require: 'fs'.
>> >
>> > Both times it said that it does not understand #require:
>> >
>> > Then I went for
>> > <var fs = require('fs');>
>> >
>> > Am I missing something here or are there parts which are not yet
>> > implemented?
>> >
>> > I want to read and write a text file in the REPL.
>> >
>> > --Hannes
>> >
>> >
>> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> >>> nodejs has a File class
>> >>>
>> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>> >>>
>> >>> with an example of
>> >>>
>> >>> var file = new node.fs.File();
>> >>> file.open("/tmp/blah", "w+");
>> >>> file.write("hello");
>> >>> file.write("world");
>> >>> file.close();
>> >>>
>> >>> How would this be written in Amber?
>> >>
>> >> The API has evolved since 0.0.1 :)
>> >> http://nodejs.org/docs/v0.4.12/api/fs.html
>> >>
>> >> There's an example in the server/ directory. FileServer.st handles
>> GET
>> >> requests (answers the contents of files) and PUT requests (write
>> to
>> >> files).
>> >>
>> >>
>> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>>
>> >>
>> >>
>> >> Cheers,
>> >> Nico
>> >>
>> >>>
>> >>> Thank you for the answer in advance
>> >>> --Hannes
>> >>>
>> >>> On 10/22/11, [hidden email] <[hidden email]>
>> wrote:
>> >>> > I wrote several nodejs examples all the way back at ESUG in
>> fact.
>> >>> > amberc
>> >>> > in
>> >>> > itself runs on node. So if you look at the examples directory
>> you find
>> >>> > several node examples. The REPL does not really give you
>> anything new -
>> >>> >
>> >>> > except for playing/experimenting of course. But the workspace is
>> better
>> >>> >
>> >>> > IMHO.
>> >>> >
>> >>> > regards' Göran
>> >>> >
>> >>> >
>> >>> > -- Sent from my HP TouchPad
>> >>> > ________________________________
>> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
>> wrote:
>> >>> > Good,
>> >>> >
>> >>> > Amber will become a "regular" scripting language in addition to
>> >>> > "living" on the browser and having a command line compiler from
>> amber
>> >>> > to Javascript!!
>> >>> >
>> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >>> >
>> >>> > amber.bat contains
>> >>> >
>> >>> > @cd "%~dp0\.."
>> >>> > @node ./repl/repl.js
>> >>> >
>> >>> > then if I start I get
>> >>> > amber>>
>> >>> >
>> >>> > What do I do next?
>> >>> >
>> >>> > help
>> >>> >
>> >>> > gives
>> >>> > nil
>> >>> >
>> >>> > how do I get out again
>> >>> >
>> >>> > exit
>> >>> > quit
>> >>> > end
>> >>> > do not work (adding a dot does not help).
>> >>> > and adding a self in front of it neither.
>> >>> >
>> >>> > A little bit of documentation is needed ......
>> >>> >
>> >>> > --Hannes
>> >>> >
>> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >>> >> Hi guys,
>> >>> >>
>> >>> >> I just pushed a simple REPL written top of node.js.
>> >>> >> You can run it with:
>> >>> >>
>> >>> >> ./bin/amber
>> >>> >>
>> >>> >> The REPL is written in Amber, you can browse the code at
>> repl/REPL.st
>> >>> >>
>> >>> >> Cheers,
>> >>> >> Nico
>> >>> >>
>> >>> >>
>> >>
>> >>
>> >>
>> >
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Nicolas Petton
Oh, I renamed repl.js to amber.js, you might want to change it in
your .bat script.

Cheers,
Nico

On Tue, 2011-10-25 at 19:45 +0000, H. Hirzel wrote:

> Thanks, but now a regression test shows:
>
> REPL 0.9-129 no longer starts whereas 0.9.124 did.
>
> --Hannes
>
>
> ==========================================================
> S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber.bat
>
> node.js:203
>         throw e; // process.nextTick error, or 'error' event on first tick
>               ^
> ReferenceError: smalltalk is not defined
>     at Object.<anonymous>
> (S:\Project\amber\NicolasPetton-amber-0.9-129\repl\repl.js:1:63)
>     at Module._compile (module.js:416:26)
>     at Object..js (module.js:434:10)
>     at Module.load (module.js:335:31)
>     at Function._load (module.js:294:12)
>     at Array.<anonymous> (module.js:454:10)
>     at EventEmitter._tickCallback (node.js:195:26)
>
> S:\Project\amber\NicolasPetton-amber-0.9-129>cd ..
>
> S:\Project\amber>cd NicolasPetton-amber-0.9-124
>
> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber.bat
> amber >>
>
> On 10/24/11, Nicolas Petton <[hidden email]> wrote:
> > Yep, the bug was in ConsoleTranscript.
> > I pushed a fix.
> >
> > Cheers,
> > Nico
> >
> > On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:
> >>
> >> Ah, my guess is that the repl tries to sedn asString to the result -
> >> expecting a Smalltalk object, but now it gets a node module instead.
> >> So Nicolas needs to check the result better I guess.
> >>
> >> regards, Göran
> >>
> >>
> >> -- Sent from my HP TouchPad
> >>
> >> ______________________________________________________________________
> >> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
> >> This brings a different error message.
> >>
> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
> >> amber >> fs := require value: 'fs'.
> >>
> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
> >> throw(error);
> >> ^
> >> TypeError: Object #<Object> has no method '_asString'
> >> at [object Object]._show_
> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
> >> at Smalltalk.send
> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
> >> <snip>
> >>
> >>
> >>
> >>
> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
> >> amber >> fs := require value: 'os'.
> >>
> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
> >> throw(error);
> >> ^
> >> TypeError: Object #<Object> has no method '_asString'
> >> at [object Object]._show_
> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
> >> at Smalltalk.send
> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
> >> <snip>
> >>
> >>
> >>
> >> S:\Project\amber\NicolasPetton-amber-0.9-124>
> >>
> >>
> >> Other ideas?
> >>
> >> --HJH
> >>
> >> On 10/24/11, Göran Krampe <[hidden email]> wrote:
> >> > require is a function. Call it as if it was a block:
> >> >
> >> > fs = require value: 'os'
> >> >
> >> > Funky, right? :)
> >> >
> >> > -- Sent from my Palm Pre 2, wohoo!
> >> >
> >> > ________________________________
> >> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
> >> >
> >> > Nico,
> >> >
> >> > thank you for the link to nodejs 0.4.12 :-)
> >> >
> >> > The FileServer.st program is an example, right? It is not used by
> >> the
> >> > "regular" server?
> >> >
> >> > Learning from FileServer.st (initialize method)
> >> >
> >> > I did
> >> >
> >> > fs := self require: 'fs'.
> >> >
> >> > It was not successful.
> >> >
> >> > Tjhen I did
> >> >
> >> > obj := Object new.
> >> > obj require: 'fs'.
> >> >
> >> > Both times it said that it does not understand #require:
> >> >
> >> > Then I went for
> >> > <var fs = require('fs');>
> >> >
> >> > Am I missing something here or are there parts which are not yet
> >> > implemented?
> >> >
> >> > I want to read and write a text file in the REPL.
> >> >
> >> > --Hannes
> >> >
> >> >
> >> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
> >> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
> >> >>> nodejs has a File class
> >> >>>
> >> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file
> >> >>>
> >> >>> with an example of
> >> >>>
> >> >>> var file = new node.fs.File();
> >> >>> file.open("/tmp/blah", "w+");
> >> >>> file.write("hello");
> >> >>> file.write("world");
> >> >>> file.close();
> >> >>>
> >> >>> How would this be written in Amber?
> >> >>
> >> >> The API has evolved since 0.0.1 :)
> >> >> http://nodejs.org/docs/v0.4.12/api/fs.html
> >> >>
> >> >> There's an example in the server/ directory. FileServer.st handles
> >> GET
> >> >> requests (answers the contents of files) and PUT requests (write
> >> to
> >> >> files).
> >> >>
> >> >>
> >> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
> >>
> >> >>
> >> >>
> >> >> Cheers,
> >> >> Nico
> >> >>
> >> >>>
> >> >>> Thank you for the answer in advance
> >> >>> --Hannes
> >> >>>
> >> >>> On 10/22/11, [hidden email] <[hidden email]>
> >> wrote:
> >> >>> > I wrote several nodejs examples all the way back at ESUG in
> >> fact.
> >> >>> > amberc
> >> >>> > in
> >> >>> > itself runs on node. So if you look at the examples directory
> >> you find
> >> >>> > several node examples. The REPL does not really give you
> >> anything new -
> >> >>> >
> >> >>> > except for playing/experimenting of course. But the workspace is
> >> better
> >> >>> >
> >> >>> > IMHO.
> >> >>> >
> >> >>> > regards' Göran
> >> >>> >
> >> >>> >
> >> >>> > -- Sent from my HP TouchPad
> >> >>> > ________________________________
> >> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
> >> wrote:
> >> >>> > Good,
> >> >>> >
> >> >>> > Amber will become a "regular" scripting language in addition to
> >> >>> > "living" on the browser and having a command line compiler from
> >> amber
> >> >>> > to Javascript!!
> >> >>> >
> >> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
> >> >>> >
> >> >>> > amber.bat contains
> >> >>> >
> >> >>> > @cd "%~dp0\.."
> >> >>> > @node ./repl/repl.js
> >> >>> >
> >> >>> > then if I start I get
> >> >>> > amber>>
> >> >>> >
> >> >>> > What do I do next?
> >> >>> >
> >> >>> > help
> >> >>> >
> >> >>> > gives
> >> >>> > nil
> >> >>> >
> >> >>> > how do I get out again
> >> >>> >
> >> >>> > exit
> >> >>> > quit
> >> >>> > end
> >> >>> > do not work (adding a dot does not help).
> >> >>> > and adding a self in front of it neither.
> >> >>> >
> >> >>> > A little bit of documentation is needed ......
> >> >>> >
> >> >>> > --Hannes
> >> >>> >
> >> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
> >> >>> >> Hi guys,
> >> >>> >>
> >> >>> >> I just pushed a simple REPL written top of node.js.
> >> >>> >> You can run it with:
> >> >>> >>
> >> >>> >> ./bin/amber
> >> >>> >>
> >> >>> >> The REPL is written in Amber, you can browse the code at
> >> repl/REPL.st
> >> >>> >>
> >> >>> >> Cheers,
> >> >>> >> Nico
> >> >>> >>
> >> >>> >>
> >> >>
> >> >>
> >> >>
> >> >
> >
> >
> >


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

Hannes Hirzel
Nico and Goran,

Good,

the bat script called 'amber.bat' I did is now

@cd "%~dp0\.."
@node ./repl/amber.js

It is in the 'bin' directory. I did it the way Goran did 'server.bat'.
I do not actually understand what the first line means.


The following example now works fine

amber >> fs := require value: 'fs'.
amber >> fs readFile: 'README.md' do: [:ex :file | console log: file
printString].

I found out about the fs method #readFile:do  from the FileServer.st
example (is in server directory) as you had suggested.





A complete write example session

S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber
amber >> fs := require value: 'fs'.
[object Object]
amber >> stream := fs createWriteStream: 'hello.txt'.
[object Object]
amber >> stream write: 'hello'.
false
amber >> stream write: 'world!'.
false
amber >> stream end.
nil
amber >>



Where can I find out which other file system methods are defined (i.e.
wrapped with Smalltalk methods)?

Have a nice day
Hannes


BTW: repl.st is still in the repl directory. Is it still used as I now
directly call amber.js in the batch script?


Ref:
Nodejs File System API documentation
http://nodejs.org/docs/v0.4.12/api/fs.html

On 10/25/11, Nicolas Petton <[hidden email]> wrote:

> Oh, I renamed repl.js to amber.js, you might want to change it in
> your .bat script.
>
> Cheers,
> Nico
>
> On Tue, 2011-10-25 at 19:45 +0000, H. Hirzel wrote:
>> Thanks, but now a regression test shows:
>>
>> REPL 0.9-129 no longer starts whereas 0.9.124 did.
>>
>> --Hannes
>>
>>
>> ==========================================================
>> S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber.bat
>>
>> node.js:203
>>         throw e; // process.nextTick error, or 'error' event on first tick
>>               ^
>> ReferenceError: smalltalk is not defined
>>     at Object.<anonymous>
>> (S:\Project\amber\NicolasPetton-amber-0.9-129\repl\repl.js:1:63)
>>     at Module._compile (module.js:416:26)
>>     at Object..js (module.js:434:10)
>>     at Module.load (module.js:335:31)
>>     at Function._load (module.js:294:12)
>>     at Array.<anonymous> (module.js:454:10)
>>     at EventEmitter._tickCallback (node.js:195:26)
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-129>cd ..
>>
>> S:\Project\amber>cd NicolasPetton-amber-0.9-124
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber.bat
>> amber >>
>>
>> On 10/24/11, Nicolas Petton <[hidden email]> wrote:
>> > Yep, the bug was in ConsoleTranscript.
>> > I pushed a fix.
>> >
>> > Cheers,
>> > Nico
>> >
>> > On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:
>> >>
>> >> Ah, my guess is that the repl tries to sedn asString to the result -
>> >> expecting a Smalltalk object, but now it gets a node module instead.
>> >> So Nicolas needs to check the result better I guess.
>> >>
>> >> regards, Göran
>> >>
>> >>
>> >> -- Sent from my HP TouchPad
>> >>
>> >> ______________________________________________________________________
>> >> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
>> >> This brings a different error message.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'fs'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'os'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>
>> >>
>> >>
>> >> Other ideas?
>> >>
>> >> --HJH
>> >>
>> >> On 10/24/11, Göran Krampe <[hidden email]> wrote:
>> >> > require is a function. Call it as if it was a block:
>> >> >
>> >> > fs = require value: 'os'
>> >> >
>> >> > Funky, right? :)
>> >> >
>> >> > -- Sent from my Palm Pre 2, wohoo!
>> >> >
>> >> > ________________________________
>> >> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>> >> >
>> >> > Nico,
>> >> >
>> >> > thank you for the link to nodejs 0.4.12 :-)
>> >> >
>> >> > The FileServer.st program is an example, right? It is not used by
>> >> the
>> >> > "regular" server?
>> >> >
>> >> > Learning from FileServer.st (initialize method)
>> >> >
>> >> > I did
>> >> >
>> >> > fs := self require: 'fs'.
>> >> >
>> >> > It was not successful.
>> >> >
>> >> > Tjhen I did
>> >> >
>> >> > obj := Object new.
>> >> > obj require: 'fs'.
>> >> >
>> >> > Both times it said that it does not understand #require:
>> >> >
>> >> > Then I went for
>> >> > <var fs = require('fs');>
>> >> >
>> >> > Am I missing something here or are there parts which are not yet
>> >> > implemented?
>> >> >
>> >> > I want to read and write a text file in the REPL.
>> >> >
>> >> > --Hannes
>> >> >
>> >> >
>> >> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> >> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> >> >>> nodejs has a File class
>> >> >>>
>> >> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>> >> >>>
>> >> >>> with an example of
>> >> >>>
>> >> >>> var file = new node.fs.File();
>> >> >>> file.open("/tmp/blah", "w+");
>> >> >>> file.write("hello");
>> >> >>> file.write("world");
>> >> >>> file.close();
>> >> >>>
>> >> >>> How would this be written in Amber?
>> >> >>
>> >> >> The API has evolved since 0.0.1 :)
>> >> >> http://nodejs.org/docs/v0.4.12/api/fs.html
>> >> >>
>> >> >> There's an example in the server/ directory. FileServer.st handles
>> >> GET
>> >> >> requests (answers the contents of files) and PUT requests (write
>> >> to
>> >> >> files).
>> >> >>
>> >> >>
>> >> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>> >>
>> >> >>
>> >> >>
>> >> >> Cheers,
>> >> >> Nico
>> >> >>
>> >> >>>
>> >> >>> Thank you for the answer in advance
>> >> >>> --Hannes
>> >> >>>
>> >> >>> On 10/22/11, [hidden email] <[hidden email]>
>> >> wrote:
>> >> >>> > I wrote several nodejs examples all the way back at ESUG in
>> >> fact.
>> >> >>> > amberc
>> >> >>> > in
>> >> >>> > itself runs on node. So if you look at the examples directory
>> >> you find
>> >> >>> > several node examples. The REPL does not really give you
>> >> anything new -
>> >> >>> >
>> >> >>> > except for playing/experimenting of course. But the workspace is
>> >> better
>> >> >>> >
>> >> >>> > IMHO.
>> >> >>> >
>> >> >>> > regards' Göran
>> >> >>> >
>> >> >>> >
>> >> >>> > -- Sent from my HP TouchPad
>> >> >>> > ________________________________
>> >> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
>> >> wrote:
>> >> >>> > Good,
>> >> >>> >
>> >> >>> > Amber will become a "regular" scripting language in addition to
>> >> >>> > "living" on the browser and having a command line compiler from
>> >> amber
>> >> >>> > to Javascript!!
>> >> >>> >
>> >> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >> >>> >
>> >> >>> > amber.bat contains
>> >> >>> >
>> >> >>> > @cd "%~dp0\.."
>> >> >>> > @node ./repl/repl.js
>> >> >>> >
>> >> >>> > then if I start I get
>> >> >>> > amber>>
>> >> >>> >
>> >> >>> > What do I do next?
>> >> >>> >
>> >> >>> > help
>> >> >>> >
>> >> >>> > gives
>> >> >>> > nil
>> >> >>> >
>> >> >>> > how do I get out again
>> >> >>> >
>> >> >>> > exit
>> >> >>> > quit
>> >> >>> > end
>> >> >>> > do not work (adding a dot does not help).
>> >> >>> > and adding a self in front of it neither.
>> >> >>> >
>> >> >>> > A little bit of documentation is needed ......
>> >> >>> >
>> >> >>> > --Hannes
>> >> >>> >
>> >> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >> >>> >> Hi guys,
>> >> >>> >>
>> >> >>> >> I just pushed a simple REPL written top of node.js.
>> >> >>> >> You can run it with:
>> >> >>> >>
>> >> >>> >> ./bin/amber
>> >> >>> >>
>> >> >>> >> The REPL is written in Amber, you can browse the code at
>> >> repl/REPL.st
>> >> >>> >>
>> >> >>> >> Cheers,
>> >> >>> >> Nico
>> >> >>> >>
>> >> >>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >
>> >
>> >
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

gokr
In reply to this post by Nicolas Petton
Regarding "other methods that are wrappaed" - here is the beauty: Nothing is wrapped!

This means you can use *everything*, and this is a killer feature of Amber. Same goes for example for jQuery - all works. Even if you throw in a new version or a completely different lib. Full js interoperability.

Otherwise Amber would have been in an impossible situation vs js IMHO.

regards, Göran



-- Sent from my Palm Pre 2, wohoo!


On Oct 26, 2011 7:24, H. Hirzel <[hidden email]> wrote:

Nico and Goran,

Good,

the bat script called 'amber.bat' I did is now

@cd "%~dp0\.."
@node ./repl/amber.js

It is in the 'bin' directory. I did it the way Goran did 'server.bat'.
I do not actually understand what the first line means.


The following example now works fine

amber >> fs := require value: 'fs'.
amber >> fs readFile: 'README.md' do: [:ex :file | console log: file
printString].

I found out about the fs method #readFile:do from the FileServer.st
example (is in server directory) as you had suggested.





A complete write example session

S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber
amber >> fs := require value: 'fs'.
[object Object]
amber >> stream := fs createWriteStream: 'hello.txt'.
[object Object]
amber >> stream write: 'hello'.
false
amber >> stream write: 'world!'.
false
amber >> stream end.
nil
amber >>



Where can I find out which other file system methods are defined (i.e.
wrapped with Smalltalk methods)?

Have a nice day
Hannes


BTW: repl.st is still in the repl directory. Is it still used as I now
directly call amber.js in the batch script?


Ref:
Nodejs File System API documentation
http://nodejs.org/docs/v0.4.12/api/fs.html

On 10/25/11, Nicolas Petton <[hidden email]> wrote:

> Oh, I renamed repl.js to amber.js, you might want to change it in
> your .bat script.
>
> Cheers,
> Nico
>
> On Tue, 2011-10-25 at 19:45 +0000, H. Hirzel wrote:
>> Thanks, but now a regression test shows:
>>
>> REPL 0.9-129 no longer starts whereas 0.9.124 did.
>>
>> --Hannes
>>
>>
>> ==========================================================
>> S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber.bat
>>
>> node.js:203
>> throw e; // process.nextTick error, or 'error' event on first tick
>> ^
>> ReferenceError: smalltalk is not defined
>> at Object.<anonymous>
>> (S:\Project\amber\NicolasPetton-amber-0.9-129\repl\repl.js:1:63)
>> at Module._compile (module.js:416:26)
>> at Object..js (module.js:434:10)
>> at Module.load (module.js:335:31)
>> at Function._load (module.js:294:12)
>> at Array.<anonymous> (module.js:454:10)
>> at EventEmitter._tickCallback (node.js:195:26)
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-129>cd ..
>>
>> S:\Project\amber>cd NicolasPetton-amber-0.9-124
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber.bat
>> amber >>
>>
>> On 10/24/11, Nicolas Petton <[hidden email]> wrote:
>> > Yep, the bug was in ConsoleTranscript.
>> > I pushed a fix.
>> >
>> > Cheers,
>> > Nico
>> >
>> > On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:
>> >>
>> >> Ah, my guess is that the repl tries to sedn asString to the result -
>> >> expecting a Smalltalk object, but now it gets a node module instead.
>> >> So Nicolas needs to check the result better I guess.
>> >>
>> >> regards, Göran
>> >>
>> >>
>> >> -- Sent from my HP TouchPad
>> >>
>> >> ______________________________________________________________________
>> >> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
>> >> This brings a different error message.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'fs'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'os'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>
>> >>
>> >>
>> >> Other ideas?
>> >>
>> >> --HJH
>> >>
>> >> On 10/24/11, Göran Krampe <[hidden email]> wrote:
>> >> > require is a function. Call it as if it was a block:
>> >> >
>> >> > fs = require value: 'os'
>> >> >
>> >> > Funky, right? :)
>> >> >
>> >> > -- Sent from my Palm Pre 2, wohoo!
>> >> >
>> >> > ________________________________
>> >> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>> >> >
>> >> > Nico,
>> >> >
>> >> > thank you for the link to nodejs 0.4.12 :-)
>> >> >
>> >> > The FileServer.st program is an example, right? It is not used by
>> >> the
>> >> > "regular" server?
>> >> >
>> >> > Learning from FileServer.st (initialize method)
>> >> >
>> >> > I did
>> >> >
>> >> > fs := self require: 'fs'.
>> >> >
>> >> > It was not successful.
>> >> >
>> >> > Tjhen I did
>> >> >
>> >> > obj := Object new.
>> >> > obj require: 'fs'.
>> >> >
>> >> > Both times it said that it does not understand #require:
>> >> >
>> >> > Then I went for
>> >> > <var fs = require('fs');>
>> >> >
>> >> > Am I missing something here or are there parts which are not yet
>> >> > implemented?
>> >> >
>> >> > I want to read and write a text file in the REPL.
>> >> >
>> >> > --Hannes
>> >> >
>> >> >
>> >> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> >> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> >> >>> nodejs has a File class
>> >> >>>
>> >> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>> >> >>>
>> >> >>> with an example of
>> >> >>>
>> >> >>> var file = new node.fs.File();
>> >> >>> file.open("/tmp/blah", "w+");
>> >> >>> file.write("hello");
>> >> >>> file.write("world");
>> >> >>> file.close();
>> >> >>>
>> >> >>> How would this be written in Amber?
>> >> >>
>> >> >> The API has evolved since 0.0.1 :)
>> >> >> http://nodejs.org/docs/v0.4.12/api/fs.html
>> >> >>
>> >> >> There's an example in the server/ directory. FileServer.st handles
>> >> GET
>> >> >> requests (answers the contents of files) and PUT requests (write
>> >> to
>> >> >> files).
>> >> >>
>> >> >>
>> >> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>> >>
>> >> >>
>> >> >>
>> >> >> Cheers,
>> >> >> Nico
>> >> >>
>> >> >>>
>> >> >>> Thank you for the answer in advance
>> >> >>> --Hannes
>> >> >>>
>> >> >>> On 10/22/11, [hidden email] <[hidden email]>
>> >> wrote:
>> >> >>> > I wrote several nodejs examples all the way back at ESUG in
>> >> fact.
>> >> >>> > amberc
>> >> >>> > in
>> >> >>> > itself runs on node. So if you look at the examples directory
>> >> you find
>> >> >>> > several node examples. The REPL does not really give you
>> >> anything new -
>> >> >>> >
>> >> >>> > except for playing/experimenting of course. But the workspace is
>> >> better
>> >> >>> >
>> >> >>> > IMHO.
>> >> >>> >
>> >> >>> > regards' Göran
>> >> >>> >
>> >> >>> >
>> >> >>> > -- Sent from my HP TouchPad
>> >> >>> > ________________________________
>> >> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
>> >> wrote:
>> >> >>> > Good,
>> >> >>> >
>> >> >>> > Amber will become a "regular" scripting language in addition to
>> >> >>> > "living" on the browser and having a command line compiler from
>> >> amber
>> >> >>> > to Javascript!!
>> >> >>> >
>> >> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >> >>> >
>> >> >>> > amber.bat contains
>> >> >>> >
>> >> >>> > @cd "%~dp0\.."
>> >> >>> > @node ./repl/repl.js
>> >> >>> >
>> >> >>> > then if I start I get
>> >> >>> > amber>>
>> >> >>> >
>> >> >>> > What do I do next?
>> >> >>> >
>> >> >>> > help
>> >> >>> >
>> >> >>> > gives
>> >> >>> > nil
>> >> >>> >
>> >> >>> > how do I get out again
>> >> >>> >
>> >> >>> > exit
>> >> >>> > quit
>> >> >>> > end
>> >> >>> > do not work (adding a dot does not help).
>> >> >>> > and adding a self in front of it neither.
>> >> >>> >
>> >> >>> > A little bit of documentation is needed ......
>> >> >>> >
>> >> >>> > --Hannes
>> >> >>> >
>> >> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >> >>> >> Hi guys,
>> >> >>> >>
>> >> >>> >> I just pushed a simple REPL written top of node.js.
>> >> >>> >> You can run it with:
>> >> >>> >>
>> >> >>> >> ./bin/amber
>> >> >>> >>
>> >> >>> >> The REPL is written in Amber, you can browse the code at
>> >> repl/REPL.st
>> >> >>> >>
>> >> >>> >> Cheers,
>> >> >>> >> Nico
>> >> >>> >>
>> >> >>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >
>> >
>> >
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Amber now includes a REPL (cool!)

gokr
In reply to this post by Nicolas Petton
First line is win-magic crap to change directory to the parent directory of the running bat file.

regards, Göran

-- Sent from my Palm Pre 2, wohoo!


On Oct 26, 2011 7:24, H. Hirzel <[hidden email]> wrote:

Nico and Goran,

Good,

the bat script called 'amber.bat' I did is now

@cd "%~dp0\.."
@node ./repl/amber.js

It is in the 'bin' directory. I did it the way Goran did 'server.bat'.
I do not actually understand what the first line means.


The following example now works fine

amber >> fs := require value: 'fs'.
amber >> fs readFile: 'README.md' do: [:ex :file | console log: file
printString].

I found out about the fs method #readFile:do from the FileServer.st
example (is in server directory) as you had suggested.





A complete write example session

S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber
amber >> fs := require value: 'fs'.
[object Object]
amber >> stream := fs createWriteStream: 'hello.txt'.
[object Object]
amber >> stream write: 'hello'.
false
amber >> stream write: 'world!'.
false
amber >> stream end.
nil
amber >>



Where can I find out which other file system methods are defined (i.e.
wrapped with Smalltalk methods)?

Have a nice day
Hannes


BTW: repl.st is still in the repl directory. Is it still used as I now
directly call amber.js in the batch script?


Ref:
Nodejs File System API documentation
http://nodejs.org/docs/v0.4.12/api/fs.html

On 10/25/11, Nicolas Petton <[hidden email]> wrote:

> Oh, I renamed repl.js to amber.js, you might want to change it in
> your .bat script.
>
> Cheers,
> Nico
>
> On Tue, 2011-10-25 at 19:45 +0000, H. Hirzel wrote:
>> Thanks, but now a regression test shows:
>>
>> REPL 0.9-129 no longer starts whereas 0.9.124 did.
>>
>> --Hannes
>>
>>
>> ==========================================================
>> S:\Project\amber\NicolasPetton-amber-0.9-129>bin\amber.bat
>>
>> node.js:203
>> throw e; // process.nextTick error, or 'error' event on first tick
>> ^
>> ReferenceError: smalltalk is not defined
>> at Object.<anonymous>
>> (S:\Project\amber\NicolasPetton-amber-0.9-129\repl\repl.js:1:63)
>> at Module._compile (module.js:416:26)
>> at Object..js (module.js:434:10)
>> at Module.load (module.js:335:31)
>> at Function._load (module.js:294:12)
>> at Array.<anonymous> (module.js:454:10)
>> at EventEmitter._tickCallback (node.js:195:26)
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-129>cd ..
>>
>> S:\Project\amber>cd NicolasPetton-amber-0.9-124
>>
>> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber.bat
>> amber >>
>>
>> On 10/24/11, Nicolas Petton <[hidden email]> wrote:
>> > Yep, the bug was in ConsoleTranscript.
>> > I pushed a fix.
>> >
>> > Cheers,
>> > Nico
>> >
>> > On Mon, 2011-10-24 at 22:28 +0200, [hidden email] wrote:
>> >>
>> >> Ah, my guess is that the repl tries to sedn asString to the result -
>> >> expecting a Smalltalk object, but now it gets a node module instead.
>> >> So Nicolas needs to check the result better I guess.
>> >>
>> >> regards, Göran
>> >>
>> >>
>> >> -- Sent from my HP TouchPad
>> >>
>> >> ______________________________________________________________________
>> >> On Oct 24, 2011 9:45 PM, H. Hirzel <[hidden email]> wrote:
>> >> This brings a different error message.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'fs'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>bin\amber
>> >> amber >> fs := require value: 'os'.
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:312
>> >> throw(error);
>> >> ^
>> >> TypeError: Object #<Object> has no method '_asString'
>> >> at [object Object]._show_
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:9808:29)
>> >> at S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:327:30
>> >> at Smalltalk.send
>> >> (S:\Project\amber\NicolasPetton-amber-0.9-124\repl\repl.js:303:11)
>> >> <snip>
>> >>
>> >>
>> >>
>> >> S:\Project\amber\NicolasPetton-amber-0.9-124>
>> >>
>> >>
>> >> Other ideas?
>> >>
>> >> --HJH
>> >>
>> >> On 10/24/11, Göran Krampe <[hidden email]> wrote:
>> >> > require is a function. Call it as if it was a block:
>> >> >
>> >> > fs = require value: 'os'
>> >> >
>> >> > Funky, right? :)
>> >> >
>> >> > -- Sent from my Palm Pre 2, wohoo!
>> >> >
>> >> > ________________________________
>> >> > On Oct 24, 2011 19:27, H. Hirzel <[hidden email]> wrote:
>> >> >
>> >> > Nico,
>> >> >
>> >> > thank you for the link to nodejs 0.4.12 :-)
>> >> >
>> >> > The FileServer.st program is an example, right? It is not used by
>> >> the
>> >> > "regular" server?
>> >> >
>> >> > Learning from FileServer.st (initialize method)
>> >> >
>> >> > I did
>> >> >
>> >> > fs := self require: 'fs'.
>> >> >
>> >> > It was not successful.
>> >> >
>> >> > Tjhen I did
>> >> >
>> >> > obj := Object new.
>> >> > obj require: 'fs'.
>> >> >
>> >> > Both times it said that it does not understand #require:
>> >> >
>> >> > Then I went for
>> >> > <var fs = require('fs');>
>> >> >
>> >> > Am I missing something here or are there parts which are not yet
>> >> > implemented?
>> >> >
>> >> > I want to read and write a text file in the REPL.
>> >> >
>> >> > --Hannes
>> >> >
>> >> >
>> >> > On 10/23/11, Nicolas Petton <[hidden email]> wrote:
>> >> >> On Sat, 2011-10-22 at 17:06 +0000, H. Hirzel wrote:
>> >> >>> nodejs has a File class
>> >> >>>
>> >> >>> http://nodejs.org/docs/v0.0.1/api.html#file_file
>> >> >>>
>> >> >>> with an example of
>> >> >>>
>> >> >>> var file = new node.fs.File();
>> >> >>> file.open("/tmp/blah", "w+");
>> >> >>> file.write("hello");
>> >> >>> file.write("world");
>> >> >>> file.close();
>> >> >>>
>> >> >>> How would this be written in Amber?
>> >> >>
>> >> >> The API has evolved since 0.0.1 :)
>> >> >> http://nodejs.org/docs/v0.4.12/api/fs.html
>> >> >>
>> >> >> There's an example in the server/ directory. FileServer.st handles
>> >> GET
>> >> >> requests (answers the contents of files) and PUT requests (write
>> >> to
>> >> >> files).
>> >> >>
>> >> >>
>> >> https://github.com/NicolasPetton/amber/blob/master/server/FileServer.st#L66
>> >>
>> >> >>
>> >> >>
>> >> >> Cheers,
>> >> >> Nico
>> >> >>
>> >> >>>
>> >> >>> Thank you for the answer in advance
>> >> >>> --Hannes
>> >> >>>
>> >> >>> On 10/22/11, [hidden email] <[hidden email]>
>> >> wrote:
>> >> >>> > I wrote several nodejs examples all the way back at ESUG in
>> >> fact.
>> >> >>> > amberc
>> >> >>> > in
>> >> >>> > itself runs on node. So if you look at the examples directory
>> >> you find
>> >> >>> > several node examples. The REPL does not really give you
>> >> anything new -
>> >> >>> >
>> >> >>> > except for playing/experimenting of course. But the workspace is
>> >> better
>> >> >>> >
>> >> >>> > IMHO.
>> >> >>> >
>> >> >>> > regards' Göran
>> >> >>> >
>> >> >>> >
>> >> >>> > -- Sent from my HP TouchPad
>> >> >>> > ________________________________
>> >> >>> > On Oct 22, 2011 4:12 PM, H. Hirzel <[hidden email]>
>> >> wrote:
>> >> >>> > Good,
>> >> >>> >
>> >> >>> > Amber will become a "regular" scripting language in addition to
>> >> >>> > "living" on the browser and having a command line compiler from
>> >> amber
>> >> >>> > to Javascript!!
>> >> >>> >
>> >> >>> > I did a amber.bat file (modeled) after server.bat for MSWindows
>> >> >>> >
>> >> >>> > amber.bat contains
>> >> >>> >
>> >> >>> > @cd "%~dp0\.."
>> >> >>> > @node ./repl/repl.js
>> >> >>> >
>> >> >>> > then if I start I get
>> >> >>> > amber>>
>> >> >>> >
>> >> >>> > What do I do next?
>> >> >>> >
>> >> >>> > help
>> >> >>> >
>> >> >>> > gives
>> >> >>> > nil
>> >> >>> >
>> >> >>> > how do I get out again
>> >> >>> >
>> >> >>> > exit
>> >> >>> > quit
>> >> >>> > end
>> >> >>> > do not work (adding a dot does not help).
>> >> >>> > and adding a self in front of it neither.
>> >> >>> >
>> >> >>> > A little bit of documentation is needed ......
>> >> >>> >
>> >> >>> > --Hannes
>> >> >>> >
>> >> >>> > On 10/22/11, Nicolas Petton <[hidden email]> wrote:
>> >> >>> >> Hi guys,
>> >> >>> >>
>> >> >>> >> I just pushed a simple REPL written top of node.js.
>> >> >>> >> You can run it with:
>> >> >>> >>
>> >> >>> >> ./bin/amber
>> >> >>> >>
>> >> >>> >> The REPL is written in Amber, you can browse the code at
>> >> repl/REPL.st
>> >> >>> >>
>> >> >>> >> Cheers,
>> >> >>> >> Nico
>> >> >>> >>
>> >> >>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >
>> >
>> >
>
>
>