Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 'let x = 1' valid F# expression?

Tags:

f#

f#-3.0

I am trying to write F# parser. According to the specification the let expression looks like:

let value-defn in expr

I am using Try F# for testing. I tried following code which is parsed without error.

#light "off"
let a = 1

Yet according to the manual, should always contain in keyword. Why is it valid F# code?

like image 583
jk_ Avatar asked Nov 06 '13 11:11

jk_


People also ask

How does let work in Scheme?

In Scheme, you can use local variables pretty much the way you do in most languages. When you enter a let expression, the let variables will be bound and initialized with values. When you exit the let expression, those bindings will disappear.

Is random variable a function?

As we know, a random variable is a rule or function that assigns a numerical value to each outcome of the experiment in a sample space. There are two types of random variables, i.e. discrete and continuous random variables.

What is a scheme expression?

A Scheme expression is a construct that returns a value, such as a variable reference, literal, procedure call, or conditional. Expression types are categorized as primitive or derived. Primitive expression types include variables and procedure calls.


1 Answers

This is actually covered by another part of the spec (A.2.1.1)

module-function-or-value-defn :

  attributesopt let function-defn

  attributesopt let value-defn

Since you are defining something in a module directly, it doesn't need the in

like image 191
John Palmer Avatar answered Oct 01 '22 16:10

John Palmer