Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:49:08+00:00 2026-05-27T09:49:08+00:00

According to the spec , a use binding requires an identifier (unlike let )

  • 0

According to the spec, a use binding requires an identifier (unlike let) instead of a pattern. Why is this? Here’s an example of a scenario that doesn’t work.

type Disposable = Resource of IDisposable

let f disposable =
  use (Resource d) = disposable //ERROR: 'use' bindings must be of the form 'use <var> = <expr>'
  ()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:49:09+00:00Added an answer on May 27, 2026 at 9:49 am

    I think the likely answer is that lots of patterns don’t make sense. For instance, how would you expect the compiler to handle the following code?

    type DisposablePair = DisposablePair of IDisposable * IDisposable
    
    let f disposablePair =
        use (DisposablePair(x,y)) = disposablePair
        ()
    

    Your weird error message is probably due to the fact that even if you were using a let binding, you’d need to bind (Resource d) rather than Resource(d) (the compiler thinks you’re declaring a new function).

    For what it’s worth, I do find the inability to use an underscore pattern to be an annoyance at times (particularly when dealing with IDisposable instances that exist only to demarcate scopes, like System.Transactions.TransactionScope). One way to generalize use bindings to handle underscores and a few other situations would be to require the right hand side of a use binding to be an IDisposable but to allow any pattern on the left hand side, so that:

    use p = v in e 
    

    would syntactically translate to something like

    let ((p:System.IDisposable) as d) = v in try e finally d.Dispose()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the JTA spec: This interface is intended for use by system level
According to this discussion , the iphone agreement says that it doesn't allow loading
The program below can generate random data according to some specs (example here is
According to the spec (Annex C), strict-mode code can't do pretty much anything that
According to this from the devise wiki I should be able to use a
I'm a little confused by this. I notice that some web APIs use the
According to the XML spec, this is the definition of an empty element: An
uniqid() function returns a 13 digits long hexadecimal number. According to the spec in
According to MSDN (Section 11.3.6 of the C# spec ): Within an instance constructor
According to what I have found so far, I can use the following code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.