mflatt
2018-11-7 18:52:30

@lexi.lambda Just to make sure it’s not an installation issue, what does raco pkg show --rx drracket report?


contact
2018-11-7 18:52:50

Hello Racketers ! If (define (my-func a b) (+ a b)) then is it possible to get '(lambda (a b) (+ a b)) out of my-func somehow? i.e. does a function f exist such that (f my-func) returns '(lambda (a b) (+ a b)) ?


lexi.lambda
2018-11-7 18:54:15

@mflatt $ raco pkg show -l --rx drracket Installation-wide: Package[*=auto] Checksum Source drracket* eafd3e7f353692693402bae51ed0e2f1d7a9c4cc (catalog "drracket" "<git://github.com/racket/drracket/?path=drracket>") drracket-plugin-lib* eafd3e7f353692693402bae51ed0e2f1d7a9c4cc (catalog "drracket-plugin-lib" "<git://github.com/racket/drracket/?path=drracket-plugin-lib>") drracket-tool-doc* eafd3e7f353692693402bae51ed0e2f1d7a9c4cc (catalog "drracket-tool-doc" "<git://github.com/racket/drracket/?path=drracket-tool-doc>") drracket-tool-lib* eafd3e7f353692693402bae51ed0e2f1d7a9c4cc (catalog "drracket-tool-lib" "<git://github.com/racket/drracket/?path=drracket-tool-lib>") User-specific for installation "development": [none]


mflatt
2018-11-7 18:55:14

Does the problem persist if you delete “doc/docindex.sqlite” and run raco setup again?


lexi.lambda
2018-11-7 18:55:46

@contact If you mean that literal list, then no. The source code for functions is not kept around at runtime.


contact
2018-11-7 18:56:31

@lexi.lambda Yes, it is what I meant. Thank you!


lexi.lambda
2018-11-7 19:01:47

@mflatt Yes, it persists.


mflatt
2018-11-7 19:08:01

Can you show the first few lines of raco setup output — the part before the “— updating info-domain tables —” section?


mflatt
2018-11-7 19:09:23

I was wondering whether it should show unexpected collection or link paths, but maybe the issue is multiple links installed, in which case raco link -l \| grep drracket might be more inetersting.


lexi.lambda
2018-11-7 19:17:04

@mflatt $ raco setup raco setup: version: 7.1.0.2 raco setup: platform: x86_64-macosx [3m] raco setup: installation name: development raco setup: variants: 3m raco setup: main collects: /Users/alexis/gits/racket/racket/racket/collects raco setup: collects paths: raco setup: /Users/alexis/Library/Racket/development/collects raco setup: /Users/alexis/gits/racket/racket/racket/collects raco setup: main pkgs: /Users/alexis/gits/racket/racket/racket/share/pkgs raco setup: pkgs paths: raco setup: /Users/alexis/gits/racket/racket/racket/share/pkgs raco setup: /Users/alexis/Library/Racket/development/pkgs raco setup: links files: raco setup: /Users/alexis/gits/racket/racket/racket/share/links.rktd raco setup: /Users/alexis/Library/Racket/development/links.rktd raco setup: main docs: /Users/alexis/gits/racket/racket/racket/doc raco setup: --- updating info-domain tables ---


lexi.lambda
2018-11-7 19:17:55

Also: $ raco link -l \| grep drracket root path: "/Users/alexis/gits/racket/racket/racket/share/pkgs/drracket" root path: "/Users/alexis/gits/racket/racket/racket/share/pkgs/drracket-plugin-lib" root path: "/Users/alexis/gits/racket/racket/racket/share/pkgs/drracket-tool-lib" root path: "/Users/alexis/gits/racket/racket/racket/share/pkgs/drracket-tool-doc"


mflatt
2018-11-7 19:44:24

Well, I’m stumped.


lexi.lambda
2018-11-7 19:46:50

I could try blowing everything I have away and starting from scratch, but I actually already did something extremely close to doing that: doing git clean -fxd from inside the main racket repo (which did not fix the problem). I could also try destroying ~/Library/Racket/development/, but I don’t know what else could possibly be influencing things.


lexi.lambda
2018-11-7 19:48:44

The only piece of potential weirdness in the environment is that I have PLTCOMPILEDROOTS=compiled/@(version):, but I don’t feel like that should be causing trouble here, especially not since I deleted all my compiled files when I did git clean -fxd and started over.


jerome.martin.dev
2018-11-7 19:55:57

@soegaard2 Hey, can we talk about urlang? I’m considering making some improvements to it and I have some questions while reading your code. 1. What do import and export do exactly? 2. I’d like to make it so that urlang doesn’t generate files by default, but returns javascript as a plain string (so that you can open an (urlang) macro anywhere and get a compiled javascript string back). Do you mind making this behavior default? 3. I’d like to generate javascript “function-style” modules, so that each generated file creates only one binding in the global scope. Example: const myModule = (function(/* import as ... */){ /* everything here is private */ return { /* exports go here */ }; })(/* imports */); I thought making an import/export system would be perfect for that. But urlang seems to already feature some kind of import/export stuff, alas different (hence my first question). Do you have any advice on how to make that possible? 4. Last question. Are you currently available to work on urlang, is it fresh in your mind, and if not, do you mind passing over some knowledge (what is WIP, what is OK, what is left to do) so that I can improve it? Thanks! (maybe I should have made an email or a new channel…)


soegaard2
2018-11-7 19:56:18

@jerome.martin.dev hi


soegaard2
2018-11-7 19:57:02

Import and export is a first step for modules in JavaScript.


soegaard2
2018-11-7 19:57:55

They are NodeJS style modules.


jerome.martin.dev
2018-11-7 19:58:13

oh, ok


soegaard2
2018-11-7 19:58:38

So importing modules defined in NodeJS ought to work.


soegaard2
2018-11-7 19:58:58

There are tools that convert NodeJS modules to something that works in the browser.


soegaard2
2018-11-7 19:59:14

jerome.martin.dev
2018-11-7 19:59:28

Yeah, I was considering using urlang as a generator for the browser directly


soegaard2
2018-11-7 20:00:18

Having a compile time configuration option to switch between NodeJS and Browser modules would be a good thing.


jerome.martin.dev
2018-11-7 20:00:30

that’s what I had in mind :slightly_smiling_face:


soegaard2
2018-11-7 20:01:06

I can remember I have thought about it - but I can’t remember whether I actually implemented anything. We can check the code though.


jerome.martin.dev
2018-11-7 20:01:24

well, the code looks a bit tied to the nodejs way right now


soegaard2
2018-11-7 20:01:47

I am available in the sense, that I’d be happy to answer questions on Urlang.


jerome.martin.dev
2018-11-7 20:02:00

that’s perfect :slightly_smiling_face:


soegaard2
2018-11-7 20:02:20

Devoting large amounts of hacking time will probably need to wait for holidays.


jerome.martin.dev
2018-11-7 20:02:34

obviously


jerome.martin.dev
2018-11-7 20:02:57

I was wondering if the code was made a long time ago, or if you worked recently on this


jerome.martin.dev
2018-11-7 20:03:16

so that I don’t bother you with some old stuff :stuck_out_tongue:


soegaard2
2018-11-7 20:03:45

Most of the code is 1–2 years old. But it isn’t abandoned :slightly_smiling_face:


jerome.martin.dev
2018-11-7 20:03:50

cool !


soegaard2
2018-11-7 20:04:20

Next school year I am taking a sabatical and intend to use Urlang to build an interactive math web-site.


jerome.martin.dev
2018-11-7 20:06:43

on my side I’d like to build websites using racket for the web, for building the server and the front applications, so everything that can improve the coding experience is welcome in my toolbox


soegaard2
2018-11-7 20:07:29

If you want to see how modules are implemented currently, see



jerome.martin.dev
2018-11-7 20:07:56

yes, that’s where it got a bit hairy :stuck_out_tongue:


soegaard2
2018-11-7 20:09:04

Let’s back up a bit. You asked about what import and export does.


soegaard2
2018-11-7 20:10:03

When Urlang compiles from Urlang to JavaScript, it will throw an “undefined identifier” error, if it meets an undefined identifier.


soegaard2
2018-11-7 20:10:41

Therefore if you need to use an identifier provided by the browser, you need to “import” it in order for Urlang not to complain.


jerome.martin.dev
2018-11-7 20:10:53

I see


soegaard2
2018-11-7 20:11:44

So for example, if you are using jquery which uses the identifier $ a lot,


soegaard2
2018-11-7 20:12:08

you will need to add an (import $) to tell Urlang that the identifier is defined.


soegaard2
2018-11-7 20:12:58

Likewise use (import Math) if you need to use, say, Math.sin()


jerome.martin.dev
2018-11-7 20:13:36

ok, then my issue is more about the fact that files are generated at compile time, it prevents me from using urlang as a runtime generator


jerome.martin.dev
2018-11-7 20:14:46

my first goal would be to separate the file generation logic from the rest of urlang


soegaard2
2018-11-7 20:15:31

When you say runtime here - do you refer to when the JavaScript runs in the browser?


jerome.martin.dev
2018-11-7 20:15:51

nope, I’m talking about the racket server runtime


jerome.martin.dev
2018-11-7 20:16:19

let’s say my server answers to a request on a url, and provides back HTML content


jerome.martin.dev
2018-11-7 20:16:43

I want javascript to be generated and inserted into the HTML content as well


soegaard2
2018-11-7 20:17:30

Okay - that can definitely be solved. Let me think a bit.


soegaard2
2018-11-7 20:19:21

I think Urlang already is doing what you want?


jerome.martin.dev
2018-11-7 20:19:57

well, right now I encapsulated urlang in a javascript macro like so: (define-simple-macro (javascript jsexpr ...) (let ([js (open-output-string)]) (parameterize ([current-urlang-run? #f] [current-urlang-echo? #t] [current-output-port js]) (urlang (urmodule jsmodule jsexpr ...))) (get-output-string js)))


jerome.martin.dev
2018-11-7 20:20:33

but I still get exports.js files created in the root of my server…


soegaard2
2018-11-7 20:20:52

Okay. Better control over generated files.


soegaard2
2018-11-7 20:21:17

I think there is a parameter somewhere…


jerome.martin.dev
2018-11-7 20:21:57

last time I checked the source, urlang was generating the exports with no conditions


soegaard2
2018-11-7 20:22:04

current-urlang-output-file, current-urlang-output-file and current-urlang-exports-file


soegaard2
2018-11-7 20:23:14

The docs aren’t exactly complete.



jerome.martin.dev
2018-11-7 20:24:03

if current-urlang-exports-file is set to #f, it’ll generate the file nonetheless


jerome.martin.dev
2018-11-7 20:24:42

I guess it’s easy to fix


jerome.martin.dev
2018-11-7 20:24:53

but I wanted your advice before doing so :slightly_smiling_face:


soegaard2
2018-11-7 20:25:07

I think that’s on purpose, since line 2287 reads:


soegaard2
2018-11-7 20:25:10

(define exports-path (or (current-urlang-exports-file) ; parameter can override (urmodule-name->exports-file-name name)))


jerome.martin.dev
2018-11-7 20:25:27

yes


soegaard2
2018-11-7 20:25:41

But the idea to have an ’dont-generate-exports is a good idea.


jerome.martin.dev
2018-11-7 20:25:58

good, I’ll make a PR then?


soegaard2
2018-11-7 20:26:24

perhaps a new parameter: current-generate-exports?


soegaard2
2018-11-7 20:26:34

yes, make an PR


soegaard2
2018-11-7 20:27:47

So far the primary goal of Urlang was to generate code that can run in NodeJS. Therefore the “direct to browser” story can definitely be improved.


jerome.martin.dev
2018-11-7 20:28:10

I’d be glad to help doing so :slightly_smiling_face:


soegaard2
2018-11-7 20:28:14

The idea behind generating NodeJS code is, that it makes testing easier during development.


soegaard2
2018-11-7 20:29:06

Running the generated JavaScript and seeing result in DrRacket is a great time saver.


soegaard2
2018-11-7 20:32:10

Btw when you modify main.rkt it’s important to regenerate bytecode files. Otherwise you will get a performance hit when you use it afterwards.


jerome.martin.dev
2018-11-7 20:35:03

mmmh, you mean using raco?


soegaard2
2018-11-7 20:35:11

yes


jerome.martin.dev
2018-11-7 20:38:15

I didn’t know there were performance issues, I thought racket generated .zo files


soegaard2
2018-11-7 20:39:21

If everything runs fine, then don’t worry.


soegaard2
2018-11-7 20:39:47

If you suddenly find yourself waiting an unreasonably time, try runnin raco setup manually.


jerome.martin.dev
2018-11-7 20:40:06

ok!


soegaard2
2018-11-7 20:40:10

The urlang compiler itself is fast enough - but the generating the compiler using nanopass can be slow.


jerome.martin.dev
2018-11-7 20:40:37

btw I think you forgot to uncomment the lang line in ffi.rkt


jerome.martin.dev
2018-11-7 20:42:02

got an error with that, but I guess it’s ok without that file


soegaard2
2018-11-7 20:42:14

huh - you are right


soegaard2
2018-11-7 20:42:47

I thought I fixed that recently.


jerome.martin.dev
2018-11-7 20:43:43

yeah, I saw your last commit :stuck_out_tongue:


jerome.martin.dev
2018-11-7 20:44:12

you fixed it in colors.rkt but not in ffi.rkt


soegaard2
2018-11-7 20:45:05

ah


soegaard2
2018-11-7 20:46:21

fixed


jerome.martin.dev
2018-11-7 20:52:34

oh, last thing


jerome.martin.dev
2018-11-7 20:53:10

there’s only a (var [a 42]) syntax, but in ES6 there’s const and let


soegaard2
2018-11-7 20:54:18

Yes. Right now the target is ES5. However let is available in extras.rkt (I think)



soegaard2
2018-11-7 20:56:49

const is not available


jerome.martin.dev
2018-11-7 20:57:45

I don’t see new though


soegaard2
2018-11-7 20:58:01

Hmm. I misremembered. The let expression is builtin:


soegaard2
2018-11-7 20:58:02

(let ((x <expr>) …) <statement> … <expr>)



soegaard2
2018-11-7 20:58:28

Remind me, what does new do?


jerome.martin.dev
2018-11-7 20:58:41

it creates a new instance from a function



jerome.martin.dev
2018-11-7 20:59:05

It’s there since JS1


soegaard2
2018-11-7 21:01:02

That needs to be added. Will you make a PR?


jerome.martin.dev
2018-11-7 21:01:06

sure!


jerome.martin.dev
2018-11-7 21:01:58

I’ll try to do all that tomorrow or this weekend, it’s getting late around here :slightly_smiling_face:


soegaard2
2018-11-7 21:02:19

Same here.


jerome.martin.dev
2018-11-7 21:02:35

I guess we’re on the same time zone


soegaard2
2018-11-7 21:02:44

I think so.


jerome.martin.dev
2018-11-7 21:03:00

glad to see some europeans around here :stuck_out_tongue:


jerome.martin.dev
2018-11-7 21:04:17

thanks for the time you accorded me!


soegaard2
2018-11-7 21:04:39

always happy to chat about Urlang


jerome.martin.dev
2018-11-7 21:04:57

:slightly_smiling_face:


jerome.martin.dev
2018-11-7 21:05:10

see you around!


christopher.milton
2018-11-7 22:55:20

@christopher.milton has joined the channel