Io Language : Exception: Object does not respond to 'URL'

467 Views Asked by At

Today I'm exercising an Io example of "seven language of seven weeks."

Example code:

futureResult := URL with("http://google.com/") @fetch
writeln("Do something immediately while fetch goes on in background...")

writeln("This will block until the result is available.")

writeln("fetched ", futureResult size, " bytes")

Running with exception:

Io$ io future.io

  Exception: Object does not respond to 'URL'
  ---------
  Object URL                           future.io 1
  CLI doFile                           Z_CLI.io 140
  CLI run                              IoState_runCLI() 1

Directly run URL in io with following error:

~$ io
Io 20110905
Io> URL

  Exception: Object does not respond to 'URL'
  ---------
  Object URL                           Command Line 1

Io> 

My environment is:

Ubuntu 14.04

2

There are 2 best solutions below

0
On BEST ANSWER

Followed post , I have done following:

$ sudo apt-get install libevent-dev
$ ./build.sh
$ ./build.sh install

URL error is fixed. But following error thrown:

Do something immediately while fetch goes on in background... This will block until the result is available. fetched Exception: Error does not respond to 'size' --------- Error size
future.io 6 Error size future.io 6 CLI doFile Z_CLI.io 140 CLI run
IoState_runCLI() 1

Post help to install Io

0
On

For anyone else like me who is years later running into this issue (or any other "Exception: Object does not respond to X" issue) while following along with Bruce Tate's Seven Languages in Seven Weeks, the solution may be this:

There are some Objects/libraries which seem like they would be included in core Io based on the documentation, but are not. You must install them as addons with eerie.

To do so, follow the instructions here. Basically, you have to look for the correct addon under the IoLanguage group on Github, and install it.

This particular issue with the URL Object is further complicated by a couple of problems I will expound upon below.

  1. There is no addon for URL, instead the functionality for URL is covered by an addon called Socket (located here.)
  2. To get eerie to install Socket, you first need to install something called libevent. I did this by going to the libevent website, downloading the most recent stable version, extracting the files to a directory, and then following the instructions on how to build libevent with CMake on the libevent github page.
  3. The Socket object seems to not have support for https. The number of websites that still use http is dwindling. Google, the website used in the example in Seven Languages in Seven Weeks, moved away from http years and years ago. The first website I was able to come across that still uses http is a Chinese news website, but you can find other examples by googling around for "Websites still using http."

After accounting for all of these issues, I finally got my version of the code to work.

url := URL with("http://xinhuanet.com/")
// Had to find a website still using http, https is unsupported by Socket.
futureResult := url @fetch
// Moved this call to own line for personal clarity
writeln("Do something immediately while fetching.")
writeln("The below statement will block until the result is available.")
writeln("fetched ", futureResult size, " bytes") // Blocks until complete

And my output looks like:

Do something immediately while fetching.
The below statement will block until the result is available.
fetched 99992 bytes